History log of /src/bin/sh/alias.c |
Revision | | Date | Author | Comments |
1.24 |
| 12-May-2025 |
kre | Fix a (probably) minor alias command bug
If run as alias '' the implementation could potentially reference uninit'd memory, potentially even leading to a SEGV, though in testing that doesn't happen, and I doubt ever could.
Note this only occurs because of some ancient code commented as "funny ksh stuff" with the seemingly exotic purpose of allowing '=' to be an alias.
Prevent even the possibility of the bug, and if nothing else, make the error message that now occurs more explicitly indicate the issue.
Note that this code (& this bug) has been in sh since rev 1.1 of this file (ie: forever in NetBSD, and before it - original ash had no aliases, so it wasn't in that, but it has been in CSRG sh since aliases were first added to that (sccs rev 1.1), in May 1992) and has never been observed or reported as a problem, that I'm aware of anyway, so I am not planning any pullups of this fix. Found by code reading alone.
|
1.23 |
| 11-May-2025 |
rillig | sh: fix a lint warning
No binary change.
|
1.22 |
| 24-Feb-2023 |
kre | branches: 1.22.2;
Allow (but do not require) the magic '--' option terminator in the builtin 'alias' command. This allows portability (not that anyone should really care with aliases) for scripts from other shells in which the alias command has options, and the -- is required to allow the first alias name to begin with a '-'.
That is, for us, alias -x='echo x' works fine, always has, and still does. But other shells treat that as an attempt to use the -x option (and maybe -= etc), and require alias -- -x='echo x'. For us that variant used to complain about the alias -- not existing (as an arg with no '=' is treated as a request to extract the value of the alias).
Posix also generally requires all standard commands (or which "alias" is one, unfortunately) to support '--' even if they have no options, for precisely this reason.
|
1.21 |
| 09-Feb-2019 |
kre | Allocate alias pointers for qsort() to use on the stack, rather than directly via malloc() so they get cleaned up correctly on error/intr.
NFCI.
|
1.20 |
| 03-Dec-2018 |
kre | Revamp aliases - as dumb an idea as they are, if we're going to have them, they should work as documented, not cause core dumps, reference after free, incorrect replacements, failing to implement alias after alias, ...
The big comment that ended: This is a good idea ------- ***NOT*** and the hack it was describing are gone.
Note that most of this was from original CVS version 1.1 code (ie: came from the original import, even before 4.4-Lite was merged. That is, May 1994. And no-one in 24.5 years noticed (or at least complained about) all the bugs (or at least, most of them)).
With these changes, aliases ought to work (if you can call it that) as they are expected to by POSIX. Now if only we could get POSIX to delete them (or make them optional)...
Changes partly inspired by similar changes made by FreeBSD, (as was the previous change to alias.c, forgot ack in commit log for that one, apologies) but done a little differently, and perhaps with a slightly better outcome.
|
1.19 |
| 02-Dec-2018 |
kre | Fix the worst of the bugs in alias processing. This has been in sh since this code was first imported (May 1994) (ie: before 4.4-Lite)
There is (much) more coming soon (the big ugly comment is going away).
This one has been separated out, as it can easily cause sh core dumps, so needs:
XXX pullup-8
(the other changes to aliases probably will not get that.)
|
1.18 |
| 01-Dec-2018 |
kre | NFC. KNF. return (x) -> return x
|
1.17 |
| 07-Oct-2018 |
rillig | When listing aliases, sort them alphabetically.
|
1.16 |
| 24-Jul-2017 |
kre | branches: 1.16.2; 1.16.4; PR bin/52348
Silence nuisance testing environments - avoid << of a negative number (a signed char -- in a hash function, the result is irrelevant, as long as it is repeatable).
|
1.15 |
| 18-Jun-2014 |
christos | branches: 1.15.16; Adjust to the new alias text libedit API.
|
1.14 |
| 18-Jun-2011 |
christos | branches: 1.14.8; 1.14.20; PR/45069: Henning Petersen: Use prototypes from builtins.h .
|
1.13 |
| 29-Oct-2010 |
stacktic | branches: 1.13.4; Initialized flag field in struct alias (Fixed PR/43281)
|
1.12 |
| 07-Aug-2003 |
agc | Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22249, verified by myself.
|
1.11 |
| 24-Nov-2002 |
christos | Fixes from David Laight: - ansification - format of output of jobs command (etc) - job identiers %+, %- etc - $? and $(...) - correct quoting of output of set, export -p and readonly -p - differentiation between nornal and 'posix special' builtins - correct behaviour (posix) for errors on builtins and special builtins - builtin printf and kill - set -o debug (if compiled with DEBUG) - cd src obj (as ksh - too useful to do without) - unset -e name, remove non-readonly variable from export list. (so I could unset -e PS1 before running the test shell...)
|
1.10 |
| 20-May-1998 |
christos | Fix dangling else warning.
|
1.9 |
| 04-Jul-1997 |
christos | Fix compiler warnings.
|
1.8 |
| 11-Jan-1997 |
tls | kill 'register'
|
1.7 |
| 16-Oct-1996 |
christos | PR/2808: Remove trailing whitespace (from FreeBSD)
|
1.6 |
| 11-May-1995 |
christos | branches: 1.6.6; Merge in my changes from vangogh, and fix the x=`false`; echo $? == 0 bug.
|
1.5 |
| 21-Mar-1995 |
cgd | convert to new RCS id conventions.
|
1.4 |
| 04-Dec-1994 |
cgd | from James Jegers <jimj@miller.cs.uwm.edu>: quiet -Wall, and squelch some of the worst style errors.
|
1.3 |
| 23-Sep-1994 |
mycroft | Eliminate uses of some obsolete functions.
|
1.2 |
| 11-Jun-1994 |
mycroft | Add RCS ids.
|
1.1 |
| 11-May-1994 |
jtc | branches: 1.1.1; Initial revision
|
1.1.1.1 |
| 11-May-1994 |
jtc | 44lite code
|
1.6.6.1 |
| 26-Jan-1997 |
rat | Update /bin/sh from trunk per request of Christos Zoulas. Fixes many bugs.
|
1.13.4.1 |
| 23-Jun-2011 |
cherry | Catchup with rmind-uvmplock merge.
|
1.14.20.1 |
| 10-Aug-2014 |
tls | Rebase.
|
1.14.8.1 |
| 19-Aug-2014 |
tls | Rebase to HEAD as of a few days ago.
|
1.15.16.1 |
| 07-Dec-2018 |
martin | Pull up following revision(s) (requested by kre in ticket #1126):
bin/sh/alias.c: revision 1.19
Fix the worst of the bugs in alias processing. This has been in sh since this code was first imported (May 1994) (ie: before 4.4-Lite)
There is (much) more coming soon (the big ugly comment is going away).
This one has been separated out, as it can easily cause sh core dumps, so needs: XXX pullup-8
(the other changes to aliases probably will not get that.)
|
1.16.4.3 |
| 21-Apr-2020 |
martin | Ooops, restore accidently removed files from merge mishap
|
1.16.4.2 |
| 21-Apr-2020 |
martin | Sync with HEAD
|
1.16.4.1 |
| 10-Jun-2019 |
christos | Sync with HEAD
|
1.16.2.2 |
| 26-Dec-2018 |
pgoyette | Sync with HEAD, resolve a few conflicts
|
1.16.2.1 |
| 20-Oct-2018 |
pgoyette | Sync with head
|
1.22.2.1 |
| 02-Aug-2025 |
perseant | Sync with HEAD
|