It's official now; Solaris sh is brain dead...

For example, this program

    #!/bin/sh

    die() { echo die called with $1; exit 1; } >&2

    die foo
    die bar

will print *both* those messages!

I honestly don't care if this is posix or not, but it is BRAIN DEAD for
the ">&2" to change the meaning from {} to ()

Oh and the grep thing is even worse.

    echo foo | grep ^/

works fine in an interactive shell but in a script it attempts to
*execute* "/", complains, while simultaneously complaining about usage
of grep.

It's almost like it's treating ^ like |
This commit is contained in:
Sitaram Chamarty 2011-10-20 15:40:17 +05:30
parent f050938171
commit 5a125fac96
4 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
die() { echo "$@"; exit 1; } >&2 die() { echo "$@" >&2; exit 1; }
[ -z "$GL_RC" ] && die "ENV GL_RC not set" [ -z "$GL_RC" ] && die "ENV GL_RC not set"
[ -z "$GL_BINDIR" ] && die "ENV GL_BINDIR not set" [ -z "$GL_BINDIR" ] && die "ENV GL_BINDIR not set"

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
die() { echo "$@"; exit 1; } >&2 die() { echo "$@" >&2; exit 1; }
# ---------- # ----------

View file

@ -18,7 +18,7 @@ GL_PACKAGE_CONF=/tmp/share/gitolite/conf
# pubkey file if you happen to have lost all gitolite-access to the repos (but # pubkey file if you happen to have lost all gitolite-access to the repos (but
# do have shell access via some other means) # do have shell access via some other means)
die() { echo "$@"; exit 1; } >&2 die() { echo "$@" >&2; exit 1; }
get_rc_val() { get_rc_val() {
`dirname $0`/gl-query-rc $1 `dirname $0`/gl-query-rc $1

View file

@ -29,10 +29,10 @@ usage() { echo "
exit 1; exit 1;
} }
die() { echo "$@"; echo; usage; exit 1; } >&2 die() { echo "$@" >&2; echo >&2; usage >&2; exit 1; }
validate_dir() { validate_dir() {
echo $1 | grep ^/ >/dev/null || die "$1 should be an absolute path" echo $1 | grep '^/' >/dev/null || die "$1 should be an absolute path"
[ -d $1 ] || mkdir -p $1 || die "$1 does not exist and could not be created" [ -d $1 ] || mkdir -p $1 || die "$1 does not exist and could not be created"
} }