-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Scott Klement wrote:

So it's better to do this:

cd /whatever && somecmd

In this case, the somecmd command is only executed if the CD command was
successful. Therefore, if the directory change doesn't work, the error
message will be the one from the cd command, and the somecmd command
won't be executed.



For completeness, note that if you substitute two pipe symbols '||'
instead of the two ampersands then the subsequent command will be
executed only if the first one failed with an error. That can
occasionally come in handy.

Thus:

do this || and do this if the prior command failed.

Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFKLwAjCFu3bIiwtTARApgnAJ0UEXb0bRdUutETdAf8o626Wz/AjwCgh4MN
q6USM3ArYt+jj00ZCvIZhRI=
=OBtW
-----END PGP SIGNATURE-----

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.