Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • 1
    Thanks. Do you know if it's possible to get the same effect as local in ksh93 in without the function-based function definitions? The reason I'm asking is I have a bunch of mostly POSIX code except with local variables and so I thought I'd make it more portable by replacing the local declarations with eval $current_shells_local_keyword $the_variables. Commented Jul 4, 2017 at 9:42
  • @PSkocik, you may want to have a look at github.com/modernish/modernish Commented Jul 4, 2017 at 9:43
  • 1
    @PSkocik, see edit for one approach. Commented Jul 4, 2017 at 10:08
  • I like your approach but ksh support wasn't essential, and I ended up ignoring it and simply doing alias local=typeset for yash. With that, my code appears to be correct in dash, bash, yash, posh, and zsh, as long as I don't rely on a specific type of scoping, the local values being auto-initialized to empty (in some shells they aren't), and on local being a keyword ( local a=$b is nonportable but local a="$b" or local a; a=$b appears to work across all the shells). Thanks for the help. Commented Jul 5, 2017 at 15:36
  • Even worse, the version of ksh93 on RHEL6.10 (shown as sh (AT&T Research) 93u+ 2012-08-01) and the version on RHEL7.8 (same version string) have different typeset behaviors, similar to the ksh88/ksh93 changes. For example: echo $HOME; typeset -u HOME; echo $HOME. On RHEL6 this uppercases $HOME. On RHEL7 this uppercases and clears $HOME. Commented Sep 9, 2021 at 15:14