Richard Hansen
2014-10-07 20:27:04 UTC
Hi all,
Like many others, I have long wanted to add new features to the shell
language such as arrays, local variables (bugs 465 and 767), and
additional parameter expansions. I recognize the perils in doing so:
They run the risk of breaking compatibility with existing scripts, not
every shell has implemented or wants to implement these features, and
those that have might have subtle but important incompatibilities.
With that in mind, I want to figure out a way to make forward progress.
I'd like to know what you think about the following proposal:
* For features that break backward compatibility with Issue 7, or for
backward-compatible features where toggling on or off makes sense,
reserve the posix_* prefix in the 'set' option namespace. For
example, 'set -o posix_local' could enable support for local
variables inside functions (in a to-be-specified manner). The
default would always be the backward-compatible setting. Testing
whether an implementation supports a particular feature can be done
by attempting to turn the feature on; if unsupported, 'set' will
return non-zero.
* For features that do not break backward compatibility with Issue 7
and that do not need to be toggled on or off, provide a way to test
whether the shell implements the feature. For example, 'set -o
posix_arrays' could return zero if arrays are supported and
non-zero otherwise (but the command would not change any state; if
arrays are supported, a plain 'set +o' or 'set -o' would either not
show posix_arrays or always show posix_arrays as enabled).
With the above mechanisms in place, we could add a non-normative future
directions section for each feature we want to add. A section would
graduate to normative (but still optional) once the kinks have been
ironed out and some existing shells have implemented the feature.
We could add meta-features to turn on a collection of independent
features that have graduated to normative, e.g., 'set -o posix_issue8'.
Thoughts?
Thanks,
Richard
Like many others, I have long wanted to add new features to the shell
language such as arrays, local variables (bugs 465 and 767), and
additional parameter expansions. I recognize the perils in doing so:
They run the risk of breaking compatibility with existing scripts, not
every shell has implemented or wants to implement these features, and
those that have might have subtle but important incompatibilities.
With that in mind, I want to figure out a way to make forward progress.
I'd like to know what you think about the following proposal:
* For features that break backward compatibility with Issue 7, or for
backward-compatible features where toggling on or off makes sense,
reserve the posix_* prefix in the 'set' option namespace. For
example, 'set -o posix_local' could enable support for local
variables inside functions (in a to-be-specified manner). The
default would always be the backward-compatible setting. Testing
whether an implementation supports a particular feature can be done
by attempting to turn the feature on; if unsupported, 'set' will
return non-zero.
* For features that do not break backward compatibility with Issue 7
and that do not need to be toggled on or off, provide a way to test
whether the shell implements the feature. For example, 'set -o
posix_arrays' could return zero if arrays are supported and
non-zero otherwise (but the command would not change any state; if
arrays are supported, a plain 'set +o' or 'set -o' would either not
show posix_arrays or always show posix_arrays as enabled).
With the above mechanisms in place, we could add a non-normative future
directions section for each feature we want to add. A section would
graduate to normative (but still optional) once the kinks have been
ironed out and some existing shells have implemented the feature.
We could add meta-features to turn on a collection of independent
features that have graduated to normative, e.g., 'set -o posix_issue8'.
Thoughts?
Thanks,
Richard