1

I'm running a sequence of commands in xterm: xterm -sb -bg black -fg white -e "pdflatex --shell-escape -file-line-error-style | && biber | && pdflatex --shell-escape -interaction nonstopmode -file-line-error-style | && pdflatex --shell-escape -interaction nonstopmode -file-line-error-style | && evince |.pdf &" (the pipes are filled in with a filename by jEdit when the command is called, but it's not a jEdit issue).

If I call it with xterm -hold it stays open and I have to close it with the mouse or with Alt+F4. If I call it without -hold it goes and I can't see what the last command to successfully finish was.

So is there a way to either:

  1. call xterm with a conditional hold or
  2. close xterm with a command when it has been invoked with -hold (typing exit closes an xterm window that has been opened without -hold, but not one that has been opened with -hold.
2
  • do you have to run it in the background?
    – suspectus
    Commented Jan 21, 2014 at 17:06
  • @suspectus I think so - that is a jEdit issue - if I don't I can't use jEdit, which means that when pdflatex throws an error I can switch to the right file or go to the right line and look at it while the error message is still up.
    – Chris H
    Commented Jan 22, 2014 at 9:07

2 Answers 2

1

If you can use bash then try this. set -o pipefail is key here - it causes bash to exit any command in a pipelined chain of commands with an exit code. With pipefail if any command in the chain fails the error status will always be zero (regardless of whether an error occured or not).

#!/bin/bash
set -o pipefail
xterm -sb -bg black -fg white -e ....  # without -hold option
wait $!                                # wait for exit status of command
if [ $? -ne 0 ];then                   # $? holds exit status, test if error occurred
        read -p "Error - press any key to exit "
fi
exit 0
3
  • I couldn't get that to work - it appeared to be ignoring the pipefail, but I suspect that was me vs. scripting vs. jEdit. Inspired by your answer I've come up with something that works, which I'll post as an answer for formatting and because it's too long for a comment.
    – Chris H
    Commented Jan 22, 2014 at 14:25
  • ok - I look forward to finding out how you solved it.
    – suspectus
    Commented Jan 22, 2014 at 14:27
  • I cheated by copy-pasting the error trap after each compile step, the rest was just wrapping up to suit jEdit.
    – Chris H
    Commented Jan 22, 2014 at 14:30
1

I failed to get the solution given by suspectus to work, but inspired by that answer I got the following to work:

I now just execute xterm -sb -bg black -fg white -e "~/.jedit/macros/LaTeX/pdflatex.sh |" & from jEdit, pdflatex.sh is as follows:

pdflatex --shell-escape -file-line-error-style $1  
if [ $? -ne 0 ]; then 
    read -p "Error - press any key to exit "
    exit 0
fi
biber $1  
if [ $? -ne 0 ]; then 
    read -p "Error - press any key to exit "
    exit 0
fi
pdflatex --shell-escape -file-line-error-style -interaction nonstopmode $1 
if [ $? -ne 0 ]; then 
    read -p "Error - press any key to exit "
    exit 0
fi
pdflatex --shell-escape -file-line-error-style -interaction nonstopmode $1 
if [ $? -ne 0 ]; then 
    read -p "Error - press any key to exit "
    exit 0
fi
nohup evince $1.pdf  & 
exit 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .