When running a script with -o posix I usually do so to make sure that the script will run anywhere with a POSIX compliant shell. Currently we support typeset when running in posix mode, where POSIX states: If the command name matches the name of a utility listed in the following table, the results are unspecified[0]. >snip< local >snip< typeset >snip<
When looking at the rationale[1] I found the following: Local variables within a function were considered and included in another early proposal (controlled by the special built-in local), but were removed because they do not fit the simple model developed for functions and because there was some opposition to adding yet another new special built-in that was not part of historical practice. Implementations should reserve the identifier local (as well as typeset, as used in the KornShell) in case this local variable mechanism is adopted in a future version of this standard. I know bash supports local and dash has the keyword, but ignores its meaning (the variables are still global), but since POSIX is pretty vague in how the keyword should be reserved I reckon it would help people who want to write portable scripts. Thoughts? Are people running -o posix in production where this could breakage? martijn@ [0] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01 [1] https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html#tag_23_02_09_18 Index: c_ksh.c =================================================================== RCS file: /cvs/src/bin/ksh/c_ksh.c,v retrieving revision 1.61 diff -u -p -r1.61 c_ksh.c --- c_ksh.c 18 May 2018 13:25:20 -0000 1.61 +++ c_ksh.c 20 Nov 2018 08:45:57 -0000 @@ -577,6 +577,11 @@ c_typeset(char **wp) /* called with 'typeset -' */ break; case 't': /* typeset */ + if (Flag(FPOSIX)) { + bi_errorf( + "typeset not supported in posixly correct mode"); + return 1; + } local = 1; break; }