Skip to main content
added 426 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

2025 edit. ksh2020 was eventually abandoned (ksh93v- turned out to be too buggy), but maintenance of ksh93 (based on ksh93u+ from 2012) was taken over as a community effort led by Martijn Dekker, with some feature and improvements taken from ksh2020 and elsewhere. A local builtin/keywork with dynamic scoping is currently being considered.

yash (written much later), has typeset (à la ksh88), but has only had local as an alias to it since version 2.48 (December 2018).

yash (written much later), has typeset (à la ksh88), but has only had local as an alias to it since version 2.48 (December 2018).

2025 edit. ksh2020 was eventually abandoned (ksh93v- turned out to be too buggy), but maintenance of ksh93 (based on ksh93u+ from 2012) was taken over as a community effort led by Martijn Dekker, with some feature and improvements taken from ksh2020 and elsewhere. A local builtin/keywork with dynamic scoping is currently being considered.

yash (written much later), has typeset (à la ksh88), but has only had local as an alias to it since version 2.48 (December 2018).

Rollback to Revision 18
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
  • typeset (ksh, pdksh, bash, zsh, yash) vs local (ksh88, pdksh, bash, zsh, ash, yash 2.48+).
  • the list of supported options.
  • static (ksh93, in function f {...} function), vs dynamic scoping (all other shells). For instance, whether function f { typeset v=1; g; echo "$v"; }; function g { v=2; }; f outputs 1 or 2. See also how the export attribute affects scoping in ksh93.
  • whether local/typeset just makes the variable local (ash, bosh), or creates a new instance of the variable (other shells). For instance, whether v=1; f() { local v; echo "${v:-empty}"; }; f outputs 1 or empty (see also the localvar_inherit option in bash 5.0 and above).
  • with those that create a new variable, whether the new one inherits the attributes (like export) and/or type and which ones from the variable in the parent scope. For instance, whether export V=1; f() { local V=2; printenv V; }; f prints 1, 2 or nothing.
  • Whether a variable with the readonly attribute in a parent scope can be created local (with that attribute or not) in a child scope.
  • whether that new variable has an initial value (empty, 0, empty list, depending on type, zsh) or is initially unset.
  • whether unset V on a variable in a local scope leaves the variable unset, or just peels one level of scoping (mksh, yash, bash under some circumstances). For instance, whether v=1; f() { local v=2; unset v; echo "$v"; } outputs 1 or nothing (see also the localvar_unset option in bash 5.0 and above)
  • like for export, whether it's a keyword or only a mere builtin or both and under what condition it's considered as a keyword.
  • like for export, whether the arguments are parsed as normal command arguments or as assignments (and under what condition).
  • whether you can declare local a variable that was readonly in the parent scope.
  • the interactions with v=value myfunction where myfunction itself declares v as local or not.
  • typeset (ksh, pdksh, bash, zsh, yash) vs local (ksh88, pdksh, bash, zsh, ash, yash 2.48+).
  • the list of supported options.
  • static (ksh93, in function f {...} function), vs dynamic scoping (all other shells). For instance, whether function f { typeset v=1; g; echo "$v"; }; function g { v=2; }; f outputs 1 or 2. See also how the export attribute affects scoping in ksh93.
  • whether local/typeset just makes the variable local (ash, bosh), or creates a new instance of the variable (other shells). For instance, whether v=1; f() { local v; echo "${v:-empty}"; }; f outputs 1 or empty (see also the localvar_inherit option in bash 5.0 and above).
  • with those that create a new variable, whether the new one inherits the attributes (like export) and/or type and which ones from the variable in the parent scope. For instance, whether export V=1; f() { local V=2; printenv V; }; f prints 1, 2 or nothing.
  • Whether a variable with the readonly attribute in a parent scope can be created local (with that attribute or not) in a child scope.
  • whether that new variable has an initial value (empty, 0, empty list, depending on type, zsh) or is initially unset.
  • whether unset V on a variable in a local scope leaves the variable unset, or just peels one level of scoping (mksh, yash, bash under some circumstances). For instance, whether v=1; f() { local v=2; unset v; echo "$v"; } outputs 1 or nothing (see also the localvar_unset option in bash 5.0 and above)
  • like for export, whether it's a keyword or only a mere builtin or both and under what condition it's considered as a keyword.
  • like for export, whether the arguments are parsed as normal command arguments or as assignments (and under what condition).
  • whether you can declare local a variable that was readonly in the parent scope.
  • the interactions with v=value myfunction where myfunction itself declares v as local or not.
  • typeset (ksh, pdksh, bash, zsh, yash) vs local (ksh88, pdksh, bash, zsh, ash, yash 2.48+).
  • the list of supported options.
  • static (ksh93, in function f {...} function), vs dynamic scoping (all other shells). For instance, whether function f { typeset v=1; g; echo "$v"; }; function g { v=2; }; f outputs 1 or 2. See also how the export attribute affects scoping in ksh93.
  • whether local/typeset just makes the variable local (ash, bosh), or creates a new instance of the variable (other shells). For instance, whether v=1; f() { local v; echo "${v:-empty}"; }; f outputs 1 or empty (see also the localvar_inherit option in bash 5.0 and above).
  • with those that create a new variable, whether the new one inherits the attributes (like export) and/or type and which ones from the variable in the parent scope. For instance, whether export V=1; f() { local V=2; printenv V; }; f prints 1, 2 or nothing.
  • whether that new variable has an initial value (empty, 0, empty list, depending on type, zsh) or is initially unset.
  • whether unset V on a variable in a local scope leaves the variable unset, or just peels one level of scoping (mksh, yash, bash under some circumstances). For instance, whether v=1; f() { local v=2; unset v; echo "$v"; } outputs 1 or nothing (see also the localvar_unset option in bash 5.0 and above)
  • like for export, whether it's a keyword or only a mere builtin or both and under what condition it's considered as a keyword.
  • like for export, whether the arguments are parsed as normal command arguments or as assignments (and under what condition).
  • whether you can declare local a variable that was readonly in the parent scope.
  • the interactions with v=value myfunction where myfunction itself declares v as local or not.
added 138 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
  • typeset (ksh, pdksh, bash, zsh, yash) vs local (ksh88, pdksh, bash, zsh, ash, yash 2.48+).
  • the list of supported options.
  • static (ksh93, in function f {...} function), vs dynamic scoping (all other shells). For instance, whether function f { typeset v=1; g; echo "$v"; }; function g { v=2; }; f outputs 1 or 2. See also how the export attribute affects scoping in ksh93.
  • whether local/typeset just makes the variable local (ash, bosh), or creates a new instance of the variable (other shells). For instance, whether v=1; f() { local v; echo "${v:-empty}"; }; f outputs 1 or empty (see also the localvar_inherit option in bash 5.0 and above).
  • with those that create a new variable, whether the new one inherits the attributes (like export) and/or type and which ones from the variable in the parent scope. For instance, whether export V=1; f() { local V=2; printenv V; }; f prints 1, 2 or nothing.
  • Whether a variable with the readonly attribute in a parent scope can be created local (with that attribute or not) in a child scope.
  • whether that new variable has an initial value (empty, 0, empty list, depending on type, zsh) or is initially unset.
  • whether unset V on a variable in a local scope leaves the variable unset, or just peels one level of scoping (mksh, yash, bash under some circumstances). For instance, whether v=1; f() { local v=2; unset v; echo "$v"; } outputs 1 or nothing (see also the localvar_unset option in bash 5.0 and above)
  • like for export, whether it's a keyword or only a mere builtin or both and under what condition it's considered as a keyword.
  • like for export, whether the arguments are parsed as normal command arguments or as assignments (and under what condition).
  • whether you can declare local a variable that was readonly in the parent scope.
  • the interactions with v=value myfunction where myfunction itself declares v as local or not.
  • typeset (ksh, pdksh, bash, zsh, yash) vs local (ksh88, pdksh, bash, zsh, ash, yash 2.48+).
  • the list of supported options.
  • static (ksh93, in function f {...} function), vs dynamic scoping (all other shells). For instance, whether function f { typeset v=1; g; echo "$v"; }; function g { v=2; }; f outputs 1 or 2. See also how the export attribute affects scoping in ksh93.
  • whether local/typeset just makes the variable local (ash, bosh), or creates a new instance of the variable (other shells). For instance, whether v=1; f() { local v; echo "${v:-empty}"; }; f outputs 1 or empty (see also the localvar_inherit option in bash 5.0 and above).
  • with those that create a new variable, whether the new one inherits the attributes (like export) and/or type and which ones from the variable in the parent scope. For instance, whether export V=1; f() { local V=2; printenv V; }; f prints 1, 2 or nothing.
  • whether that new variable has an initial value (empty, 0, empty list, depending on type, zsh) or is initially unset.
  • whether unset V on a variable in a local scope leaves the variable unset, or just peels one level of scoping (mksh, yash, bash under some circumstances). For instance, whether v=1; f() { local v=2; unset v; echo "$v"; } outputs 1 or nothing (see also the localvar_unset option in bash 5.0 and above)
  • like for export, whether it's a keyword or only a mere builtin or both and under what condition it's considered as a keyword.
  • like for export, whether the arguments are parsed as normal command arguments or as assignments (and under what condition).
  • whether you can declare local a variable that was readonly in the parent scope.
  • the interactions with v=value myfunction where myfunction itself declares v as local or not.
  • typeset (ksh, pdksh, bash, zsh, yash) vs local (ksh88, pdksh, bash, zsh, ash, yash 2.48+).
  • the list of supported options.
  • static (ksh93, in function f {...} function), vs dynamic scoping (all other shells). For instance, whether function f { typeset v=1; g; echo "$v"; }; function g { v=2; }; f outputs 1 or 2. See also how the export attribute affects scoping in ksh93.
  • whether local/typeset just makes the variable local (ash, bosh), or creates a new instance of the variable (other shells). For instance, whether v=1; f() { local v; echo "${v:-empty}"; }; f outputs 1 or empty (see also the localvar_inherit option in bash 5.0 and above).
  • with those that create a new variable, whether the new one inherits the attributes (like export) and/or type and which ones from the variable in the parent scope. For instance, whether export V=1; f() { local V=2; printenv V; }; f prints 1, 2 or nothing.
  • Whether a variable with the readonly attribute in a parent scope can be created local (with that attribute or not) in a child scope.
  • whether that new variable has an initial value (empty, 0, empty list, depending on type, zsh) or is initially unset.
  • whether unset V on a variable in a local scope leaves the variable unset, or just peels one level of scoping (mksh, yash, bash under some circumstances). For instance, whether v=1; f() { local v=2; unset v; echo "$v"; } outputs 1 or nothing (see also the localvar_unset option in bash 5.0 and above)
  • like for export, whether it's a keyword or only a mere builtin or both and under what condition it's considered as a keyword.
  • like for export, whether the arguments are parsed as normal command arguments or as assignments (and under what condition).
  • whether you can declare local a variable that was readonly in the parent scope.
  • the interactions with v=value myfunction where myfunction itself declares v as local or not.
added 10 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 34 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 79 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 76 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 64 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 723 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 723 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 37 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
edited body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 124 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 287 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
edited body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
edited body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
edited body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 643 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 130 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
added 655 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k
Loading