Robert Elz wrote in <23334.1727160...@jacaranda.noi.kre.to>: | Date: Tue, 24 Sep 2024 03:06:49 +0300 | From: Valery Ushakov <u...@stderr.spb.ru> | Message-ID: <zvicmrzqjrjob...@snips.stderr.spb.ru> | || I also wanted to drop the ${1+"$@"} workaroud for the v7 shell bug || which I'm pretty sure we are not going to hit in this day and age on a || NetBSD system, but I won't to get down that rabbit hole. | |That one isn't a rabbit hole, by all means, go ahead and delete that |usage, you are unlikely to find broken "$@" in any shell anyone would |actually want to use any more - that was a truly ancient bug being |worked around, as distinct from a difference from what is required, |which return being ignored in a script is.
Sven Maschek [1]: Which Bourne shells exactly need the workaround? These shells behave the old way and need ${1+"$@"}: Certainly: /bin/sh on 7th edition (aka Version 7). And thus also /bin/sh on original BSDs, until these shipped the Almquist shell (after 4.3BSD-Reno) HP-UX 8, 9 /bin/sh, HP-UX 10.x, 11.x /usr/old/bin/sh (as /bin/sh has become a ksh) OSF1/V4 and V5 aka Tru64 /bin/sh Ultrix /bin/sh and /bin/sh5 Sinix 5.20 /bin/sh in both the "ucb" and the "sie" universe In contrast, these Bourne shell variants behave the modern way: 8th edition (aka Version 8) /bin/sh SunOS 4.1.x and SunOS 5.x /bin/sh IRIX 5 - IRIX 6.3 /bin/sh, IRIX 6.4+x /usr/bin/bsh (as /usr/bin/sh has become a ksh) AIX 3.2.4 /bin/sh, AIX 4.x /usr/bin/bsh (as /usr/bin/sh has become a ksh) OpenServer 3 ff. /usr/bin/sh MUNIX 3.1 (Cadmus, SVR3.1) /bin/sh Sinix 5.20 /bin/sh in the "xopen" universe Oh wait, there's another meaning It's also a workaround for a problem in some shells if you want to use the flag u ("error upon using empty variables") and "$@" (or $@, "$*", $*) is used without arguments. Example: $ shell -cu 'echo "$@"; echo not reached' @: parameter not set $ shell -cu 'echo ${1+"$@"}; echo ok' ok At least these shells need that workaround: bash-4.0.0 ... -4.0.27 ^ Somewhere around 2010. dash-0.4.6 ... -0.4.18 all ksh88 ksh93 until release t+20090501 pdksh-5.1.3, -5.2.14 mksh before R39 (as pdksh descendant) posh < 0.10 (as pdksh descendant) NetBSD 2 ff. /bin/sh all traditional Bourne shells [1] https://www.in-ulm.de/~mascheck/various/bourne_args/ --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)