1) Fix mkdir -p to exit with the proper exit status and issue an error
message if it was unable to create all of the specified directories
and they did not previously exist. POSIX says:
The mkdir utility shall exit with one of the following values:
0 All the specified directories were created successfully or the
-p option was specified and all the specified directories now
exist.
E.g.
% mkdir -p /var/mkdir
mkdir: /var/mkdir: Permission denied
% touch /tmp/file
% mkdir -p /tmp/file/dir
mkdir: /tmp/file: Not a directory
Previously the above examples would exit with a zero exit status
and no error message. Something like the following run as a
normal user will still not produce an error:
% id
uid=629(mpp) gid=629(mpp)....
% mkdir -p /usr/local/etc
% ls -ld /usr/local/etc
drwxr-xr-x 4 bin bin 512 Dec 26 14:55 /usr/local/etc/
2) Cleaned up the mode handling to be more efficient when multiple
directories are being created.
3) Fixed a problem where directories could be created with the wrong mode
if the the -p option was specified and the build() routine returned
and error. It would leave the umask set incorrectly at this point.
4) Removed an unused variable.
Closes PR# 2304.
- Use MAP_FAILED instead of the constant -1 to indicate
failure (required by POSIX).
- Removed flag arguments of '0' (required by POSIX).
- Fixed code which expected an error return of 0.
- Fixed code which thought any address with the high bit set
was an error.
- Check for failure where no checks were present.
Discussed with: bde
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.
while remaining (becoming :) compatible with other popular shells.
Specifically these changes include:
1) Implement 'trap -l' to get a list of valid signals names. This
is useful if you wanted to do something like reset all signal
handlers to there defaults values, in which case something like
this will do the trick.
trap `trap -l`
2) Reformat the output of 'trap' so it can be saved and later eval'd
to restore the saved settings.
3) Allow the use of signal names as well as signal numbers.
4) Fix trap handling of SIGCHLD so that commands like the following
(albeit, contrived) won't cause sh(1) to recurse ad infinitum.
trap uname 0 20
5) Make variables static that are used only in trap.c.
6) Minor 'style(9) police' mods.
now handles the getpwd() init problem the same way as bash
and ksh do. Also while I was in here, I cleaned up the format
a little, removed some unnnecessary #if SYMLINKS cruft, and
changed the pwd builtin to use getcwd(3) as Joerg suggested.
getopts should now work as expected. This fix was in the NetBSD
code that I was merging from but missed getting into FreeBSD's
version because of 'drain bamage' on my part.
Submitted by: NetBSD, joerg