[Slackbuilds-users] pushd on /bin/sh scripts
rworkman at slackbuilds.org
Thu Feb 22 03:58:12 UTC 2007
-----BEGIN PGP SIGNED MESSAGE-----
Lehman Black wrote:
> The following SlackBuilds have pushd/popd in them and have their shell type
> incorrectly labeled as /bin/sh.
Yes, we discussed that on the development list.
This one is *all* my fault - it had never occurred to me that
pushd/popd was bash-only until it came up in conversation on
an unrelated topic. Those will be corrected as soon as possible.
I *think* the consensus we reached was that bash-isms are strongly
discouraged, but if there's simply no good way around it, make sure
the script has #!/bin/bash instead of #!/bin/sh.
As an aside, the primary (only?) reason for using pushd/popd instead
of subshells was concerns with error checking. To explain:
$ ls /test
file1 file2 file3
$ cd /test
$ ls file4 || exit1
[shell exits since file4 is not found]
$ ( ls file4 || exit 1 )
In this case, the subshell exits, but since it was a subshell, it
does not affect the calling shell. In a SlackBuild script, it is
often desirable to bail out of the entire script if one of the
subshells errors out. Some ways to do it have already been addressed
in the archives.
For our purposes, the use of this:
should accomplish what we want if a subshell is not desirable.
Anyway, thanks for the report - especially the nice list of
affected scripts :)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.2 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the Slackbuilds-users