[Cialug] bash return values [was: enter passwords less]
Chris Freeman
cwfreeman at gmail.com
Tue Aug 21 09:28:14 CDT 2007
On 8/20/07, Jeffrey C. Ollie <jeff at ocjtech.us> wrote:
>
>
...
> So when ssh-agent doesn't have your identity cached it still prints a
> line of text which messes up the comparison. However, by checking the
> exit code of 'ssh-add -l' I was able to get it to work:
...
I've got a trick which helps me remember to always use the exit code in my
scripts instead of relying on the output of a program. This also helps me
keep track of my current working directory and machine name, without pushing
my prompt to the right edge of the screen.
I recommend to all users who ever script in bash/ksh/sh to use a prompt like
the following:
# Prompt with the last exit vale, the word 'HOME', and the current working
directory.
# Note the single-quotes, not double-quotes or back-tics.
export PS1='[$?]-HOME->$PWD
$ ';
Clearly, you'll have up to 1/2 of your screen taken up with data you didn't
have before, but you start to really rely on that data in short order. Put
whatever data you need out there.
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20070821/e93f5e35/attachment-0001.html
More information about the Cialug
mailing list