History log of /freebsd-current/bin/sh/alias.c
Revision Date Author Comments
# e043f372 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

bin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 90aea514 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 2fc4a84e 29-Apr-2023 Piotr Pawel Stefaniak <pstef@FreeBSD.org>

sh: introduce a function to iterate over all aliases

Currently the data structure holding alias information is opaque for
consumers outside alias.c and there is no way to iterate over all
aliases, which will become needed by a future commit.

The new function "iteralias" takes a null pointer to return the first
alias or an existing alias to return the next one, unless there is
no alias to return, in which case it returns a null pointer.

I slightly changed the static function hashalias so that it returns the
index into the array holding link heads, and not the link head directly.
In this form it's easier to use by iteralias and the slight adjustment
in the three existing callers doesn't look too bad.

Differential Revision: https://reviews.freebsd.org/D40619


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 026dfd4a 16-Apr-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix use after free when resetting an in-use alias.

The special case of modifying an existing alias does not work correctly if
the alias is currently in use. Instead, handle this case by unaliasing the
old alias (if any) and then creating a new alias.


# 773e27ae 16-Apr-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix unalias -a while an alias is currently in use.

It is a rare situation to modify aliases while an alias is currently in use,
but this is handled for plain unalias. Handle it for unalias -a as well.


# 05e626c3 02-Apr-2017 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Remove an XXX comment: it is normal for builtins to use argptr.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 2ece3386 21-Feb-2016 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Don't hash alias name when there are no aliases.


# c3c85727 24-Jun-2015 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix some arithmetic undefined behaviour.

Fix shifts of possibly negative numbers found with ubsan and avoid signed
integer overflow when hashing an extremely long command name.

MFC after: 1 week


# 1632bf1a 26-Mar-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix possible memory leaks and double frees with unexpected SIGINT.


# 4b489a60 24-Jan-2014 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Solve the alias recursion problem in a less hackish way.

Add the space to avoid alias recursion when the alias is expanded, not when
it is added.

As a result, displaying an alias via command -v, command -V or type no
longer erroneously appends a space. Adjust the tests so they now require
this bug to be absent.


# 71828da5 25-Aug-2013 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Recognize "--" as end of options in alias builtin.

Aliases starting with "-" (which are non-POSIX) will need to be preceded by
an alias not starting with "-" or the newly added "--".


# e964872f 08-Nov-2012 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix two issues when an alias is redefined:

* The last character is not displayed.
* If the alias ends with itself (as a word), an infinite memory-eating loop
occurs.

If an alias is defined initially, a space is appended to avoid recursion but
this did not happen when an alias was later modified.

PR: bin/173418
Submitted by: Daniel F.
MFC after: 1 week


# 454a02b3 13-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Fix duplicate prototypes for builtins.

Have mkbuiltins write the prototypes for the *cmd functions to builtins.h
instead of builtins.c and include builtins.h in more .c files instead of
duplicating prototypes for *cmd functions in other headers.


# 47a5ab29 04-Jun-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Reduce more needless differences between error messages.


# 3835f47c 04-Feb-2011 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Remove special code for shell scripts without magic number.

These are called "shell procedures" in the source.

If execve() failed with [ENOEXEC], the shell would reinitialize itself
and execute the program as a script. This requires a fair amount of code
which is not frequently used (most scripts have a #! magic number).
Therefore just execute a new instance of sh (_PATH_BSHELL) to run the
script.


# 5fe9123f 21-Dec-2010 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Add a function to print warnings (with command name and newline).
This is like error() but without raising an exception.
It is particularly useful as a replacement for the warnx macro in
bltin/bltin.h.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 88328642 13-Oct-2010 David E. O'Brien <obrien@FreeBSD.org>

In the spirit of r90111, depend on c89 and remove the "STATIC" macro
and its usage.


# aa7b6f82 12-Oct-2010 David E. O'Brien <obrien@FreeBSD.org>

Consistently use "STATIC" for all functions in order to be able to set
breakpoints with in a debugger. And use naked "static" for variables.

Noticed by: bde


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 2cac6e36 24-Dec-2009 Jilles Tjoelker <jilles@FreeBSD.org>

sh: Constify various strings.

Most of this is adding const keywords, but setvar() in var.c had to be
changed somewhat more.


# ac08b882 01-Jun-2009 Ralf S. Engelschall <rse@FreeBSD.org>

be more type correct and align local ckmalloc() with its underlying malloc(3) by using a "size_t" instead of an "int" argument


# d4b1e374 22-Mar-2009 Stefan Farfeleder <stefanf@FreeBSD.org>

- Apply the r190270 changes to printing of single aliases too.
- Sort the aliases before printing them.


# 0de913c3 22-Mar-2009 Stefan Farfeleder <stefanf@FreeBSD.org>

Make the output of the alias built-in POSIX-compliant: Drop the leading 'alias'
and suppress printing the trailing space which is added for internal purposes.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# a65d88d1 07-Jun-2008 Ralf S. Engelschall <rse@FreeBSD.org>

use 'const' for the parameters of the two static functions unalias() and hashalias()


# 401b3c20 07-Jun-2008 Ralf S. Engelschall <rse@FreeBSD.org>

remove an unnecessary include


# dbf2e1c5 02-Sep-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Return 1 from the unalias builtin if _any_ removal fails, not just the last
one.


# c7893739 13-Aug-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Use prototypes in the MKINIT lines collected by mkinit.


# 6195fb41 06-Apr-2004 Mark Murray <markm@FreeBSD.org>

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# 2ba1b30b 05-Jul-2003 Diomidis Spinellis <dds@FreeBSD.org>

Changes following CScout analysis:

- Removed dead declarations
- Made objects that should have been declared as static, static.

The changes use STATIC instead of static, following the existing
convention in the rest of the code.

Approved by: schweikh (mentor)
MFC after: 2 weeks


# 2749b141 29-Jun-2002 David E. O'Brien <obrien@FreeBSD.org>

Consistently use FBSDID


# e5341cbb 03-Jun-2002 Tim J. Robbins <tjr@FreeBSD.org>

Quote alias values in the output of the alias(1) builtin so they are
suitable for re-input to the shell (SUSv3)


# 5134c3f7 01-Feb-2002 Warner Losh <imp@FreeBSD.org>

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.
o Change
int
foo() {
...
to
int
foo(void)
{
...


# 410fb0ac 15-Jul-2000 SADA Kenji <sada@FreeBSD.org>

Fixd with alias missing.

PR: bin/19475
Approved by: Martin Cracauer <cracauer@cons.org> (with conditions)


# 2a456239 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 46be34b9 08-May-1999 Kris Kennaway <kris@FreeBSD.org>

Various spelling/formatting changes.

Submitted by: Philippe Charnier <charnier@xp11.frmug.org>


# 3d7b5b93 18-May-1998 Philippe Charnier <charnier@FreeBSD.org>

Add rcsid. Spelling.


# e7a0b024 18-May-1997 Steve Price <steve@FreeBSD.org>

Use the __unused attribute where warranted.


# afb033d5 27-Apr-1997 Steve Price <steve@FreeBSD.org>

Nuke register keyword usage and #if -> #ifdef.

Obtained from: NetBSD


# b97fa2ef 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# ab0a2172 13-Dec-1996 Steve Price <steve@FreeBSD.org>

Merge in NetBSD mods and -Wall cleaning.

Obtained from: NetBSD, me


# aa9caaf6 01-Sep-1996 Peter Wemm <peter@FreeBSD.org>

Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is a
merge of parallel duplicate work by Steve Price and myself. :-]

There are some changes to the build that are my fault... mkinit.c was
trying (poorly) to duplicate some of the work that make(1) is designed to
do. The Makefile hackery is my fault too, the depend list was incomplete
because of some explicit OBJS+= entries, so mkdep wasn't picking up their
source file #includes.

This closes a pile of /bin/sh PR's, but not all of them..

Submitted by: Steve Price <steve@bonsai.hiwaay.net>, peter


# 069428af 26-May-1996 Peter Wemm <peter@FreeBSD.org>

Import the 4.4BSD-Lite2 /bin/sh sources

Requested by: joerg

(Note, this is mostly going to be conflicts, which is expected. Our entire
sh source has a mainline, so this should not change anything except for
a few new files appearing. I dont think they are a problem)


# 2162b2d2 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.

Reviewed by: phk


# 89730b29 23-Sep-1994 David Greenman <dg@FreeBSD.org>

Added $Id$


# 4b88c807 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite bin Sources