mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
The commit that backported read -a did not add a case label for it
to read.c. This was under the assumption that AST optget(3) would
always convert -a to -A. However, that was only done for first use.
The cause is the short-form options caching mechanism in optget(3).
On the first run, the pre-caching result would be returned, but the
equivalent option (-a) would be cached as if it is its own option,
so on the second and subsequent runs, optget returned 'a' instead
of 'A'. This only happens if no long-form equivalent is present.
Reproducer:
$ read -A foo <<< 'foo bar baz'
$ unset foo
$ read -a foo <<< 'foo bar baz'
$ echo ${foo[0]}
foo bar baz
Expected: foo
src/lib/libast/misc/optget.c,
src/lib/libast/misc/optlib.h:
- [by Martijn Dekker] Implement caching for short-option
equivalents. If a short-form equivalent is found, instead of
caching it as a separate option, cache the equivalent in a new
equiv[] array. Check this when reading the cache and substitute
the main option for the equivalent if one is cached.
src/lib/libcmd/cp.c:
- Fix cp -r/cp -R symlink handling. The -r and -R options sometimes
ignored -P, -L and -H.
- The -r and -R options no longer follow symlinks by default.
src/cmd/ksh93/bltins/whence.c,
src/lib/libcmd/*.c:
- Remove case labels that are redundant now that the optget(3)
caching bug is fixed.
src/cmd/ksh93/tests/libcmd.sh:
- Added. This is the new script for the /opt/ast/bin path-bound
built-ins from libcmd. Other relevant tests are moved into here.
Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
aa1f8244e6
commit
bea4fd56e8
12 changed files with 400 additions and 210 deletions
|
|
@ -71,6 +71,7 @@ typedef struct Optcache_s
|
|||
Optpass_t pass;
|
||||
int caching;
|
||||
unsigned char flags[sizeof(OPT_FLAGS)];
|
||||
char equiv[sizeof(OPT_FLAGS)]; /* short option equivalents */
|
||||
} Optcache_t;
|
||||
|
||||
typedef struct Optstate_s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue