Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler error on OS X 10.6 #1465

Closed
wants to merge 3,402 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
3402 commits
Select commit Hold shift + click to select a range
13f4a8c
Fix typo
krader1961 Aug 27, 2019
a724383
Move the `whence` documentation into a text file
krader1961 Aug 26, 2019
44fb5d5
Move the other builtin command docs into ext files
krader1961 Aug 26, 2019
f5ae4ee
Add comment explaining why `sh_set[]` isn't externalized
krader1961 Aug 26, 2019
a226181
Move libcmd into the ksh tree
krader1961 Aug 27, 2019
62fdca2
More builtin documention moved to external files
krader1961 Aug 26, 2019
282247d
Move more documentation out of the source code
krader1961 Aug 27, 2019
b0a1984
Lint cleanup
krader1961 Aug 28, 2019
e6e79c9
Remove deprecated cppcheck option
krader1961 Aug 28, 2019
da4f59d
cppcheck lint cleanup
krader1961 Aug 28, 2019
d0d07c6
Move b_command() into its own module
krader1961 Aug 28, 2019
2bf7a27
Refactor `export` and `readonly`
krader1961 Aug 28, 2019
3d3e417
Move b_alias() into its own module
krader1961 Aug 29, 2019
e3eb5e1
Move b_builtin() into its own module
krader1961 Aug 29, 2019
90f9b53
Move b_set() into its own module
krader1961 Aug 29, 2019
75f9c39
Move b_set() into its own module
krader1961 Aug 29, 2019
0b46d8c
Fix definition of `print_scan()` function
siteshwar Aug 29, 2019
15f781f
Make `print_scan()` function non-static
siteshwar Aug 29, 2019
13d6ace
Readd header needed on 32-bit platforms
krader1961 Aug 29, 2019
208c23d
Refactor bg_fg_disown.c
krader1961 Aug 29, 2019
7f1061c
Refactor module true_false.c
krader1961 Aug 29, 2019
6a372af
Refactor break_continue.c and return_exit.c
krader1961 Aug 29, 2019
5e0ff94
Refactor cd_pwd.c
krader1961 Aug 29, 2019
fb2e95b
Remove unsed, broken, "hash" builtin
krader1961 Aug 29, 2019
9ba9355
Enable code predicated on _c99_in_the_wild
krader1961 Aug 29, 2019
d5277d3
Refactor b_unset(), b_unalias, and unall()
krader1961 Aug 30, 2019
32d8131
Release ksh-2020.0.0-beta1
siteshwar Aug 30, 2019
0f44849
Remove dup `b_pwd()` leftover from previous refactoring
krader1961 Aug 30, 2019
36d688a
Move `sig_number()` out of trap.c
krader1961 Aug 30, 2019
990f237
Separate b_trap() and b_kill()
krader1961 Aug 30, 2019
e069b75
Eliminate pointless `Bltin()` preprocessor macro
krader1961 Aug 30, 2019
4de8a51
IWYU lint
krader1961 Aug 31, 2019
d89753b
Skip API test if build type != debug
krader1961 Sep 1, 2019
cb9f6d3
Ensure USER is set when unit tests run
krader1961 Sep 1, 2019
dc9fccc
Replace e_astbin with SH_CMDLIB_DIR
krader1961 Sep 2, 2019
a54c289
Introduce ${.sh.install_prefix}
krader1961 Sep 2, 2019
2d497fb
Make the code less fragile
krader1961 Sep 3, 2019
2bce63a
Switch to a more idiomatic end-of-table check
krader1961 Sep 3, 2019
657c587
Fix various typos found by codespell
hosiet Sep 3, 2019
a9d4bb0
Replace commit 2d497fbc with a better approach
krader1961 Sep 4, 2019
44463c0
Make b_times.exp unit test more robust
krader1961 Sep 6, 2019
24e968c
Convert `alias` documentation to Sphinx/RST
krader1961 Aug 31, 2019
fa9673c
Switch b_alias() from optget() to getopt_long()
krader1961 Sep 1, 2019
a08307c
Implement `man` function
krader1961 Sep 3, 2019
d0f92b4
Convert b_basename() to getopt_long()
krader1961 Sep 4, 2019
f4c1514
Changes to make the tests pass
krader1961 Sep 8, 2019
f124433
Cygwin source compatibility
krader1961 Sep 10, 2019
780492b
Lint: suggest parentheses around ‘&&’ within ‘||’
krader1961 Sep 11, 2019
3bd5b4f
Move b_echo() into its own module
krader1961 Sep 11, 2019
6153a5a
Fix shellcheck errors
krader1961 Sep 11, 2019
fca4d53
Switch b_bg() from optget() to getopt_long()
krader1961 Sep 11, 2019
0101139
Switch b_fg() from optget() to getopt_long()
krader1961 Sep 11, 2019
d49d8de
Switch b_break() from optget() to getopt_long()
krader1961 Sep 11, 2019
6d55cdc
Use `MESON_INSTALL_DESTDIR_PREFIX` variable
siteshwar Sep 11, 2019
9c9a5c8
[packaging] Add missing files in rpm builds
siteshwar Sep 11, 2019
244d9cc
[packaging] Fix rpm builds on opensuse
siteshwar Sep 11, 2019
ce77f93
Convert b_basename() to getopt_long()
krader1961 Sep 4, 2019
c085cbc
Introduce builtin_usage_error()
krader1961 Sep 12, 2019
d5d60da
Switch b_builtin() from optget() to getopt_long()
krader1961 Sep 11, 2019
c0abef8
Switch b_cat() from optget() to getopt_long()
krader1961 Sep 11, 2019
a2f9d59
Switch b_cd() from optget() to getopt_long()
krader1961 Sep 12, 2019
0f8af10
Switch b_chmod() from optget() to getopt_long()
krader1961 Sep 12, 2019
9487319
IWYU lint
krader1961 Sep 13, 2019
0ba0a7b
Switch b_cmp() from optget() to getopt_long()
krader1961 Sep 13, 2019
2102308
Switch b_command() from optget() to getopt_long()
krader1961 Sep 13, 2019
1687f3b
Switch to POSIXLY_CORRECT option parsing
krader1961 Sep 13, 2019
c4f582d
Fix expansion of bare tildes when HOME is unset
floppym Sep 5, 2019
6ef2ca5
make man
krader1961 Sep 13, 2019
7c174b5
Switch b_continue() from optget() to getopt_long()
krader1961 Sep 14, 2019
96b19ee
Correct which optget_long() error handling
krader1961 Sep 14, 2019
0f05131
Switch b_cut() from optget() to getopt_long()
krader1961 Sep 14, 2019
2b6e821
Don't assume `no_argument` is zero
krader1961 Sep 14, 2019
8aa6eea
Switch b_dirname() from optget() to getopt_long()
krader1961 Sep 14, 2019
b935f1a
Switch b_disown() from optget() to getopt_long()
krader1961 Sep 14, 2019
a421fe8
Switch b_source() from optget() to getopt_long()
krader1961 Sep 14, 2019
c682318
Document fix for issue #1391
krader1961 Sep 14, 2019
c44e124
Use sphinx to generate the docs if available
krader1961 Sep 14, 2019
bc155a2
Create echo.rst document
krader1961 Sep 15, 2019
c3a2b14
Switch b_enum() from optget() to getopt_long()
krader1961 Sep 15, 2019
62fd830
Man page rst cleanups
krader1961 Sep 15, 2019
9484249
Commit more Sphinx build artifacts
krader1961 Sep 15, 2019
d9491d4
Fix regression involving `command` builtin
krader1961 Sep 15, 2019
8aa9ac9
Switch b_eval() from optget() to getopt_long()
krader1961 Sep 15, 2019
1da542f
Switch b_exec() from optget() to getopt_long()
krader1961 Sep 15, 2019
e0c4882
Switch b_exit() from optget() to getopt_long()
krader1961 Sep 16, 2019
57085ad
Switch b_export() from optget() to getopt_long()
krader1961 Sep 16, 2019
c584641
Switch b_head() from optget() to getopt_long()
krader1961 Sep 16, 2019
695269a
Switch b_hist() from optget() to getopt_long()
krader1961 Sep 16, 2019
66d0976
Commit more Sphinx build artifacts
krader1961 Sep 16, 2019
1c9e7ab
Revert "Switch b_hist() from optget() to getopt_long()"
krader1961 Sep 17, 2019
91a75b9
Normalize sentinel value of a Shtable_t[]
krader1961 Sep 17, 2019
1eb928a
run_test.sh: exit with status 77 when skipping a test
floppym Sep 17, 2019
25f73f4
Initialize the jobs table earlier
krader1961 Sep 18, 2019
1893891
Switch b_hist() from optget() to getopt_long()
krader1961 Sep 19, 2019
4c9c596
Fix and normalize handling of atypical CLI flags
krader1961 Sep 19, 2019
98bc42a
Make unit test compatible with Cygwin
krader1961 Sep 19, 2019
3dffc9d
Switch b_jobs() from optget() to getopt_long()
krader1961 Sep 20, 2019
abe5bd6
Switch b_kill() from optget() to getopt_long()
krader1961 Sep 20, 2019
957ce01
Fix `exit` getopt_long() short options
krader1961 Sep 20, 2019
376b085
Fix `head` handling of integer flags
krader1961 Sep 20, 2019
abf06c2
Remove support for negative ints from `bg` and `fg`
krader1961 Sep 20, 2019
7368706
Man page style improvements
krader1961 Sep 20, 2019
c3aa2d5
Switch b_let() from optget() to getopt_long()
krader1961 Sep 20, 2019
46215d4
Switch b_logname() from optget() to getopt_long()
krader1961 Sep 21, 2019
eb8e227
Switch b_mkdir() from optget() to getopt_long()
krader1961 Sep 21, 2019
0ffecb0
man: Silence mandoc warnings in ksh.1.
orbea Sep 21, 2019
7c17e44
bin/style all
krader1961 Sep 21, 2019
7b5953c
eliminate some unused preprocessor symbols
krader1961 Sep 21, 2019
f4d7c1b
Add more `print -R` tests
krader1961 Sep 22, 2019
6993358
Refactor b_print(), b_echo(), and b_printf()
krader1961 Sep 22, 2019
08ab0ec
Remove `login` and `newgrp` special builtins
krader1961 Sep 24, 2019
1885d04
Switch b_print() from optget() to getopt_long()
krader1961 Sep 24, 2019
72e1624
Switch b_printf() from optget() to getopt_long()
krader1961 Sep 25, 2019
7f06b58
Switch b_pwd() from optget() to getopt_long()
krader1961 Sep 25, 2019
4e401a9
Switch b_read() from optget() to getopt_long()
krader1961 Sep 25, 2019
4f00fdb
Switch b_readonly() from optget() to getopt_long()
krader1961 Sep 25, 2019
8bdfa5b
Switch b_return() from optget() to getopt_long()
krader1961 Sep 25, 2019
857b058
Change naming of ksh script based tests
krader1961 Sep 25, 2019
1b34915
Fix regression involving invalid char class name
krader1961 Sep 27, 2019
2828fd9
Eliminate Meson warning about our config file
krader1961 Sep 28, 2019
07e8829
Coverity Scan lint cleanup
krader1961 Sep 29, 2019
8031fed
Remove pointless checks of malloc() failing
krader1961 Sep 29, 2019
762f838
Switch shcomp from optget() to getopt_long()
krader1961 Sep 30, 2019
ce7e096
Switch b_shift() from optget() to getopt_long()
krader1961 Sep 30, 2019
3be7e10
Switch b_sleep() from optget() to getopt_long()
krader1961 Sep 30, 2019
461707e
Switch b_sync() from optget() to getopt_long()
krader1961 Oct 1, 2019
cfec3cb
Switch b_test() from optget() to getopt_long()
krader1961 Oct 1, 2019
5c3052b
Switch b_times() from optget() to getopt_long()
krader1961 Oct 1, 2019
394ba62
Switch b_trap() from optget() to getopt_long()
krader1961 Oct 1, 2019
39bf126
Switch b_ulimit() from optget() to getopt_long()
krader1961 Oct 1, 2019
541a7d4
Switch b_umask() from optget() to getopt_long()
krader1961 Oct 2, 2019
3955a1c
Switch b_unalias() from optget() to getopt_long()
krader1961 Oct 2, 2019
485fb82
bin/style all
krader1961 Oct 2, 2019
fcd6535
Lint cleanup
krader1961 Oct 2, 2019
31aec52
Switch b_uname() from optget() to getopt_long()
krader1961 Oct 2, 2019
f8a6aa6
Switch b_unset() from optget() to getopt_long()
krader1961 Oct 2, 2019
28592fc
Switch b_wait() from optget() to getopt_long()
krader1961 Oct 3, 2019
44d6381
Switch b_wc() from optget() to getopt_long()
krader1961 Oct 3, 2019
c68faf0
Switch b_whence() from optget() to getopt_long()
krader1961 Oct 3, 2019
e02c662
Simplify nv_addtype()
krader1961 Oct 3, 2019
45ea282
Remove the `type` builtin
krader1961 Oct 3, 2019
669656b
Switch b_complete() from optget() to getopt_long()
krader1961 Oct 4, 2019
e30225b
make man
krader1961 Oct 4, 2019
7005717
Enable the expect based tests on FreeBSD
krader1961 Oct 4, 2019
2095983
Fix `complete` flag handling
krader1961 Oct 5, 2019
c3098f7
Improve handling of unit test timeouts
krader1961 Oct 6, 2019
c52d3a3
Enable real-time signal test
krader1961 Oct 7, 2019
b18d4ae
Fix meson status of skipped shcomp tests
krader1961 Oct 9, 2019
a5ecd1c
Cleanup feature test artifacts
krader1961 Oct 10, 2019
ad9d63d
Show version number through `ksh --version`
siteshwar Oct 9, 2019
f5d2e83
Update changelog with stable version number
siteshwar Oct 9, 2019
d2e31cc
Move the logic for skipping tests
krader1961 Oct 9, 2019
d1de147
Minor spelling fixes
aweeraman Oct 19, 2019
ddfe6b3
Implement an optget() like alternative
krader1961 Oct 14, 2019
7faa294
Switch from getopt_long() to optget_long()
krader1961 Oct 19, 2019
a9b86b6
Convert some getopt_long_only() to optget_long()
krader1961 Oct 19, 2019
84648ca
Convert remaining getopt_long_only()
krader1961 Oct 21, 2019
856f994
Add more optget_long() unit tests
krader1961 Oct 25, 2019
e7713a5
Try to reduce false positive expect test failures
krader1961 Oct 27, 2019
2df35bd
style --all
krader1961 Oct 28, 2019
c791a0d
Silence Coverity Scan lint warning
krader1961 Oct 28, 2019
7f5e094
Silence some bogus IWYU compiler warnings
krader1961 Oct 28, 2019
bd87dbf
Remove irrelevant assignment
krader1961 Oct 28, 2019
0d96c25
Silence lint warning about uninitialized var
krader1961 Oct 28, 2019
8e019ec
Silence lint: "Null pointer dereference"
krader1961 Oct 28, 2019
0451612
cppcheck lint elimination
krader1961 Oct 28, 2019
fec0369
silence cppcheck lint warnings
krader1961 Oct 28, 2019
a32b02c
silence cppcheck lint warnings
krader1961 Oct 28, 2019
d9103c8
Remove a couple of no longer needed cppcheck suppressions
krader1961 Oct 28, 2019
dd2c8ea
Make `DPRINTF()` more robust
krader1961 Oct 29, 2019
4a5d206
Use `static_fn` rather than `static`
krader1961 Oct 29, 2019
4503830
Update Travis "fedora" config
krader1961 Oct 29, 2019
9490d10
Correct invalid argv[-1]
krader1961 Oct 30, 2019
6511635
Silence cppcheck warning about argv[-1]
krader1961 Oct 30, 2019
651e614
Fix `cd` function and make it automatically available
krader1961 Oct 26, 2019
286203f
Run autoloaded functions through shellcheck
krader1961 Oct 30, 2019
886d86f
Fix errors due to wchar_t being two bytes
krader1961 Oct 31, 2019
f867740
Adapt unit test to new Travis Fedora env
krader1961 Oct 31, 2019
c6c8c0c
Eliminate some pointless log file content
krader1961 Nov 1, 2019
42e8a04
Eliminate command help on error if not interactive
krader1961 Nov 1, 2019
1a34ebd
lower test parallelism on travis macos
krader1961 Nov 2, 2019
2580181
enable malloc debug on travis macos
krader1961 Nov 2, 2019
b058d8c
Fix b_sync.sh test failures on some macOS systems
krader1961 Nov 2, 2019
11983a7
Fix fallback addrs2info()
danyspin97 Nov 2, 2019
8e4c8f0
Fix for test failures when home directory is not available
aweeraman Nov 3, 2019
4a438e5
Move the generated version from a .h to a .c file
krader1961 Nov 5, 2019
91b3806
Revert "Move the generated version from a .h to a .c file"
krader1961 Nov 7, 2019
a205e5a
Tweak to the -s argument and the log message to match
aweeraman Nov 3, 2019
a3c2dfb
Fix hist_nearend()
krader1961 Nov 8, 2019
c584768
Lint cleanup
krader1961 Nov 8, 2019
c25958e
Remove unused header siglist.h
krader1961 Nov 8, 2019
ffbfaf6
"unknown flag" -> "unknown option"
krader1961 Nov 8, 2019
a0c44c9
Fix ed_expand()
krader1961 Nov 10, 2019
7df11de
`functions` with not loaded autoloaded functions
krader1961 Nov 13, 2019
7c92227
Regression tests for `typeset -f` fix
krader1961 Nov 15, 2019
d72c3a6
Move the generated version from a .h to a .c file
krader1961 Nov 15, 2019
c99e9ff
Improve style of sh_close()
krader1961 Nov 15, 2019
359bf21
Add instructions for installing with MacPorts
ryandesign Nov 16, 2019
0525de9
Disable flakey API unit test
krader1961 Nov 17, 2019
42a580c
Add comment regarding the need to keep "Version A"
krader1961 Nov 20, 2019
c1af9c6
Add missing optional header
krader1961 Nov 29, 2019
61cfd45
Cleanup: remove unused function
krader1961 Nov 29, 2019
9c7211b
Improve meson warning message wording
krader1961 Nov 29, 2019
2806b21
Lint: Dangerous assignment
krader1961 Dec 1, 2019
5c16e8d
Lint cleanup
krader1961 Dec 1, 2019
ca8c7e6
Remove description of case modification operator
siteshwar Dec 9, 2019
fbaf00e
Lint: negativeIndex
krader1961 Dec 2, 2019
f05b619
Lint: invalidPointerCast
krader1961 Dec 2, 2019
82d4f30
Use the ksh semantic version in docs
krader1961 Dec 15, 2019
6928edc
Fix bug introduced by commit 6542e5a3
krader1961 Dec 5, 2019
d0a7db5
Fix shellcheck warnings created by previous commit
krader1961 Dec 15, 2019
bc901af
Enable shellcheck of standard ksh functions
krader1961 Dec 16, 2019
02525a3
Enable shellcheck on more shell scripts
krader1961 Dec 16, 2019
5efb243
Fix shellcheck errors
krader1961 Dec 16, 2019
c7de8b6
Harden env var imports
krader1961 Dec 13, 2019
c007254
Fix unit test build on NetBSD
krader1961 Dec 19, 2019
c6757a2
Fix unit test build on NetBSD
krader1961 Dec 20, 2019
b6be7e7
Harden unit test against slow test environments
krader1961 Dec 20, 2019
0d76ee4
Add option to disable */shcomp test variants
krader1961 Dec 22, 2019
2950ede
Deal with PATH being unset when running unit tests
krader1961 Dec 26, 2019
74c34dc
Move empty PATH workaround into global config
krader1961 Dec 28, 2019
d9ecc21
Fix a unit test that assumes FPATH is unset
krader1961 Dec 28, 2019
37cb9ea
Harden the test runner against a bad $PATH
krader1961 Dec 29, 2019
db20aab
Update for compatibility with macOS on TravisCI
krader1961 Dec 29, 2019
5abcbd0
Eliminate $NO_SHCOMP env var
krader1961 Dec 29, 2019
3bc5816
Fix handling of skipped directories
krader1961 Jan 9, 2020
80cc081
Avoid false positive failures of b_time.exp
krader1961 Jan 10, 2020
031d73a
Fix b_printf.sh unit test on Cygwin
krader1961 Jan 10, 2020
078cb99
Clarify how to run unit tests
krader1961 Jan 11, 2020
55cad1d
Fix potential fd leak
krader1961 Jan 12, 2020
2f9b39e
Fix b_print.sh unit test on Cygwin
krader1961 Jan 12, 2020
6b6146e
Simplify invalid locale testing
krader1961 Jan 13, 2020
b29a24d
Print correct version string on `ksh --version`
krader1961 Jan 15, 2020
b277665
Eliminate unneeded use of `getconf`
krader1961 Jan 15, 2020
2f06a34
Eliminate bogus locale tests
krader1961 Jan 15, 2020
127d2e4
Remove another `getconf LIBPATH`
krader1961 Jan 16, 2020
0641d89
Remove another bogus getconf use
krader1961 Jan 16, 2020
f80d386
Move `cd` command so `cd ~-` works
krader1961 Jan 16, 2020
d5f4cb6
Remove the remaining bogus `getconf` mention
krader1961 Jan 17, 2020
9fa5b47
Remove unused e_crondir var
krader1961 Jan 20, 2020
2986f8b
Integrate nv_optimize() bug fix from OpenSuse
krader1961 Jan 20, 2020
46d4981
Replace `0` with `NULL` to clarify intent
krader1961 Jan 20, 2020
1fd82bd
Fix interactive restricted shell behavior
krader1961 Jan 22, 2020
459a380
Eliminate pointless external getconf use
krader1961 Jan 24, 2020
3dfc236
Fix cd function and enable it in unit tests
krader1961 Nov 26, 2019
5000e7f
Rename three vars associated with cd related funcs
krader1961 Jan 26, 2020
43d1853
Suppress false-positive shellcheck warnings
krader1961 Jan 26, 2020
db54d36
Change default build type to "minsize"
krader1961 Jan 27, 2020
8cf92b2
Fix typo in the project name
krader1961 Feb 1, 2020
f8290d2
Fix compiler error on OS X 10.6
krader1961 Feb 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More builtin documention moved to external files
Move the libcmd builtin documentation into files separate from the
source code.

Related #507
  • Loading branch information
krader1961 committed Aug 28, 2019
commit 62fdca2b3aefb181c99c1f08ad672842c338ba71
34 changes: 2 additions & 32 deletions src/cmd/ksh93/cmds/basename.c
Original file line number Diff line number Diff line change
@@ -30,42 +30,12 @@

#include <string.h>

#include "builtins.h"
#include "error.h"
#include "option.h"
#include "sfio.h"
#include "shcmd.h"

static const char usage[] =
"[-?\n@(#)$Id: basename (AT&T Research) 2010-05-06 $\n]" USAGE_LICENSE
"[+NAME?basename - strip directory and suffix from filenames]"
"[+DESCRIPTION?\bbasename\b removes all leading directory components "
"from the file name defined by \astring\a. If the file name defined by "
"\astring\a has a suffix that ends in \asuffix\a, it is removed as "
"well.]"
"[+?If \astring\a consists solely of \b/\b characters the output will be "
"a single \b/\b. Trailing "
"\b/\b characters are removed, and if there are any remaining \b/\b "
"characters in \astring\a, all characters up to and including the last "
"\b/\b are removed. Finally, if \asuffix\a is specified, and is "
"identical the end of \astring\a, these characters are removed. The "
"characters not removed from \astring\a will be written on a single line "
"to the standard output.]"
"[a:all?All operands are treated as \astring\a and each modified "
"pathname is printed on a separate line on the standard output.]"
"[s:suffix?All operands are treated as \astring\a and each modified "
"pathname, with \asuffix\a removed if it exists, is printed on a "
"separate line on the standard output.]:[suffix]"
"\n"
"\n string [suffix]\n"
"string ...\n"
"\n"
"[+EXIT STATUS?]"
"{"
"[+0?Successful Completion.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\bdirname\b(1), \bgetconf\b(1), \bbasename\b(3)]";

static void namebase(Sfio_t *outfile, char *pathname, char *suffix) {
char *first, *last;
int n = 0;
@@ -106,7 +76,7 @@ int b_basename(int argc, char **argv, Shbltin_t *context) {
int n;

if (cmdinit(argc, argv, context, 0)) return -1;
while ((n = optget(argv, usage))) {
while ((n = optget(argv, sh_optbasename))) {
switch (n) { //!OCLINT(MissingDefaultStatement)
case 'a':
all = 1;
43 changes: 2 additions & 41 deletions src/cmd/ksh93/cmds/cat.c
Original file line number Diff line number Diff line change
@@ -33,51 +33,12 @@
#include <string.h>

#include "ast.h"
#include "builtins.h"
#include "error.h"
#include "option.h"
#include "sfio.h"
#include "shcmd.h"

static const char usage[] =
"[-?\n@(#)$Id: cat (AT&T Research) 2013-09-13 $\n]" USAGE_LICENSE
"[+NAME?cat - concatenate files]"
"[+DESCRIPTION?\bcat\b copies each \afile\a in sequence to the standard"
" output. If no \afile\a is given, or if the \afile\a is \b-\b,"
" \bcat\b copies from standard input starting at the current location.]"

"[b:number-nonblank?Number lines as with \b-n\b but omit line numbers from"
" blank lines.]"
"[d:dos-input?Input files are opened in \atext\amode which removes carriage"
" returns in front of new-lines on some systems.]"
"[e?Equivalent to \b-vE\b.]"
"[n:number?Causes a line number to be inserted at the beginning of each line.]"
"[s?Equivalent to \b-S\b for \aatt\a universe and \b-B\b otherwise.]"
"[t?Equivalent to \b-vT\b.]"
"[u:unbuffer?The output is not delayed by buffering.]"
"[v:show-nonprinting|print-chars?Print characters as follows: space and "
"printable characters as themselves; control characters as \b^\b "
"followed by a letter of the alphabet; and characters with the high bit "
"set as the lower 7 bit character prefixed by \bM^\b for 7 bit "
"non-printable characters and \bM-\b for all other characters. If the 7 "
"bit character encoding is not ASCII then the characters are converted "
"to ASCII to determine \ahigh bit set\a, and if set it is cleared and "
"converted back to the native encoding. Multibyte characters in the "
"current locale are treated as printable characters.]"
"[A:show-all?Equivalent to \b-vET\b.]"
"[B:squeeze-blank?Multiple adjacent new-line characters are replace by one"
" new-line.]"
"[D:dos-output?Output files are opened in \atext\amode which inserts carriage"
" returns in front of new-lines on some systems.]"
"[E:show-ends?Causes a \b$\b to be inserted before each new-line.]"
"[S:silent?\bcat\b is silent about non-existent files.]"
"[T:show-blank?Causes tabs to be copied as \b^I\b and formfeeds as \b^L\b.]"

"\n"
"\n[file ...]\n"
"\n"

"[+SEE ALSO?\bcp\b(1), \bgetconf\b(1), \bpr\b(1)]";

static char *stdin_argv[] = {"-", NULL};

#define RUBOUT 0177
@@ -354,7 +315,7 @@ int b_cat(int argc, char **argv, Shbltin_t *context) {
if (cmdinit(argc, argv, context, 0)) return -1;
att = !path_is_bsd_universe();
mode = "r";
while ((flag = optget(argv, usage))) {
while ((flag = optget(argv, sh_optcat))) {
n = 0;
switch (flag) { //!OCLINT(MissingDefaultStatement)
case 'A':
98 changes: 2 additions & 96 deletions src/cmd/ksh93/cmds/chmod.c
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@

#include "ast.h"
#include "ast_assert.h"
#include "builtins.h"
#include "error.h"
#include "option.h"
#include "sfio.h"
@@ -49,101 +50,6 @@
#endif
#endif

static const char usage[] =
"[-?\n@(#)$Id: chmod (AT&T Research) 2012-04-20 $\n]" USAGE_LICENSE
"[+NAME?chmod - change the access permissions of files]"
"[+DESCRIPTION?\bchmod\b changes the permission of each file "
"according to mode, which can be either a symbolic representation "
"of changes to make, or an octal number representing the bit "
"pattern for the new permissions.]"
"[+?Symbolic mode strings consist of one or more comma separated list "
"of operations that can be perfomed on the mode. Each operation is of "
"the form \auser\a \aop\a \aperm\a where \auser\a is zero or more of "
"the following letters:]{"
"[+u?User permission bits.]"
"[+g?Group permission bits.]"
"[+o?Other permission bits.]"
"[+a?All permission bits. This is the default if none are specified.]"
"}"
"[+?The \aperm\a portion consists of zero or more of the following letters:]{"
"[+r?Read permission.]"
"[+s?Setuid when \bu\b is selected for \awho\a and setgid when \bg\b "
"is selected for \awho\a.]"
"[+w?Write permission.]"
"[+x?Execute permission for files, search permission for directories.]"
"[+X?Same as \bx\b except that it is ignored for files that do not "
"already have at least one \bx\b bit set.]"
"[+l?Exclusive lock bit on systems that support it. Group execute "
"must be off.]"
"[+t?Sticky bit on systems that support it.]"
"}"
"[+?The \aop\a portion consists of one or more of the following characters:]{"
"[++?Cause the permission selected to be added to the existing "
"permissions. | is equivalent to +.]"
"[+-?Cause the permission selected to be removed to the existing "
"permissions.]"
"[+=?Cause the permission to be set to the given permissions.]"
"[+&?Cause the permission selected to be \aand\aed with the existing "
"permissions.]"
"[+^?Cause the permission selected to be propagated to more "
"restrictive groups.]"
"}"
"[+?Symbolic modes with the \auser\a portion omitted are subject to "
"\bumask\b(2) settings unless the \b=\b \aop\a or the "
"\b--ignore-umask\b option is specified.]"
"[+?A numeric mode is from one to four octal digits (0-7), "
"derived by adding up the bits with values 4, 2, and 1. "
"Any omitted digits are assumed to be leading zeros. The "
"first digit selects the set user ID (4) and set group ID "
"(2) and save text image (1) attributes. The second digit "
"selects permissions for the user who owns the file: read "
"(4), write (2), and execute (1); the third selects permissions"
"for other users in the file's group, with the same values; "
"and the fourth for other users not in the file's group, with "
"the same values.]"

"[+?For symbolic links, by default, \bchmod\b changes the mode on the file "
"referenced by the symbolic link, not on the symbolic link itself. "
"The \b-h\b options can be specified to change the mode of the link. "
"When traversing directories with \b-R\b, \bchmod\b either follows "
"symbolic links or does not follow symbolic links, based on the "
"options \b-H\b, \b-L\b, and \b-P\b.]"

"[+?When the \b-c\b or \b-v\b options are specified, change notifications "
"are written to standard output using the format, "
"\b%s: mode changed to %0.4o (%s)\b, with arguments of the "
"pathname, the numeric mode, and the resulting permission bits as "
"would be displayed by the \bls\b command.]"

"[+?For backwards compatibility, if an invalid option is given that is a valid "
"symbolic mode specification, \bchmod\b treats this as a mode "
"specification rather than as an option specification.]"

"[H:metaphysical?Follow symbolic links for command arguments; otherwise don't "
"follow symbolic links when traversing directories.]"
"[L:logical|follow?Follow symbolic links when traversing directories.]"
"[P:physical|nofollow?Don't follow symbolic links when traversing directories.]"
"[R:recursive?Change the mode for files in subdirectories recursively.]"
"[c:changes?Describe only files whose permission actually change.]"
"[f:quiet|silent?Do not report files whose permissioins fail to change.]"
"[h|l:symlink?Change the mode of symbolic links on systems that "
"support \blchmod\b(2). Implies \b--physical\b.]"
"[i:ignore-umask?Ignore the \bumask\b(2) value in symbolic mode "
"expressions. This is probably how you expect \bchmod\b to work.]"
"[n:show?Show actions but do not change any file modes.]"
"[F:reference?Omit the \amode\a operand and use the mode of \afile\a "
"instead.]:[file]"
"[v:verbose?Describe changed permissions of all files.]"
"\n"
"\nmode file ...\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?All files changed successfully.]"
"[+>0?Unable to change mode of one or more files.]"
"}"
"[+SEE ALSO?\bchgrp\b(1), \bchown\b(1), \blchmod\b(1), \btw\b(1), \bgetconf\b(1), "
"\bls\b(1), \bumask\b(2)]";

#ifndef ENOSYS
#define ENOSYS EINVAL
#endif
@@ -172,7 +78,7 @@ int b_chmod(int argc, char **argv, Shbltin_t *context) {
// invocations, to terminate the loop even though they look like unrecognized short flags.
//
bool optget_done = false;
while (!optget_done && (flag = optget(argv, usage))) {
while (!optget_done && (flag = optget(argv, sh_optchmod))) {
switch (flag) {
case 'c':
notify = 1;
49 changes: 2 additions & 47 deletions src/cmd/ksh93/cmds/cmp.c
Original file line number Diff line number Diff line change
@@ -37,57 +37,12 @@
#include <sys/stat.h>
#include <sys/types.h>

#include "builtins.h"
#include "error.h"
#include "option.h"
#include "sfio.h"
#include "shcmd.h"

static const char usage[] =
"[-?\n@(#)$Id: cmp (AT&T Research) 2010-04-11 $\n]" USAGE_LICENSE
"[+NAME?cmp - compare two files]"
"[+DESCRIPTION?\bcmp\b compares two files \afile1\a and \afile2\a. "
"\bcmp\b writes no output if the files are the same. By default, if the "
"files differ, the byte and line number at which the first difference "
"occurred are written to standard output. Bytes and lines are numbered "
"beginning with 1.]"
"[+?If \askip1\a or \askip2\a are specified, or the \b-i\b option is "
"specified, initial bytes of the corresponding file are skipped before "
"beginning the compare. The skip values are in bytes or can have a "
"suffix of \bk\b for kilobytes or \bm\b for megabytes.]"
"[+?If either \afile1\a or \afiles2\a is \b-\b, \bcmp\b uses standard "
"input starting at the current location.]"
"[b:print-bytes?Print differing bytes as 3 digit octal values.]"
"[c:print-chars?Print differing bytes as follows: non-space printable "
"characters as themselves; space and control characters as \b^\b "
"followed by a letter of the alphabet; and characters with the high bit "
"set as the lower 7 bit character prefixed by \bM^\b for 7 bit space and "
"non-printable characters and \bM-\b for all other characters. If the 7 "
"bit character encoding is not ASCII then the characters are converted "
"to ASCII to determine \ahigh bit set\a, and if set it is cleared and "
"converted back to the native encoding. Multibyte characters in the "
"current locale are treated as printable characters.]"
"[d:differences?Print at most \adifferences\a differences using "
"\b--verbose\b output format. \b--differences=0\b is equivalent to "
"\b--silent\b.]#[differences]"
"[i:ignore-initial|skip?Skip the the first \askip1\a bytes in \afile1\a "
"and the first \askip2\a bytes in \afile2\a. If \askip2\a is omitted "
"then \askip1\a is used.]:[skip1[::skip2]]:=0::0]"
"[l:verbose?Write the decimal byte number and the differing bytes (in "
"octal) for each difference.]"
"[n:count|bytes?Compare at most \acount\a bytes.]#[count]"
"[s:quiet|silent?Write nothing for differing files; return non-zero exit "
"status only.]"
"\n"
"\nfile1 file2 [skip1 [skip2]]\n"
"\n"
"[+EXIT STATUS?]"
"{"
"[+0?The files or portions compared are identical.]"
"[+1?The files are different.]"
"[+>1?An error occurred.]"
"}"
"[+SEE ALSO?\bcomm\b(1), \bdiff\b(1), \bcat\b(1)]";

#define CMP_VERBOSE 0x01
#define CMP_SILENT 0x02
#define CMP_CHARS 0x04
@@ -235,7 +190,7 @@ int b_cmp(int argc, char **argv, Shbltin_t *context) {
int flags = 0;

if (cmdinit(argc, argv, context, 0)) return -1;
while ((n = optget(argv, usage))) {
while ((n = optget(argv, sh_optcmp))) {
switch (n) { //!OCLINT(MissingDefaultStatement)
case 'b':
flags |= CMP_BYTES;
50 changes: 2 additions & 48 deletions src/cmd/ksh93/cmds/cut.c
Original file line number Diff line number Diff line change
@@ -34,59 +34,13 @@
#include <wchar.h>

#include "ast.h"
#include "builtins.h"
#include "error.h"
#include "option.h"
#include "sfio.h"
#include "shcmd.h"
#include "stk.h"

static const char usage[] =
"[-?\n@(#)$Id: cut (AT&T Research) 2010-08-11 $\n]" USAGE_LICENSE
"[+NAME?cut - cut out selected columns or fields of each line of a file]"
"[+DESCRIPTION?\bcut\b bytes, characters, or character-delimited fields "
"from one or more files, contatenating them on standard output.]"
"[+?The option argument \alist\a is a comma-separated or blank-separated "
"list of positive numbers and ranges. Ranges can be of three "
"forms. The first is two positive integers separated by a hyphen "
"(\alow\a\b-\b\ahigh\a), which represents all fields from \alow\a to "
"\ahigh\a. The second is a positive number preceded by a hyphen "
"(\b-\b\ahigh\a), which represents all fields from field \b1\b to "
"\ahigh\a. The last is a positive number followed by a hyphen "
"(\alow\a\b-\b), which represents all fields from \alow\a to the "
"last field, inclusive. Elements in the \alist\a can be repeated, "
"can overlap, and can appear in any order. The order of the "
"output is that of the input.]"
"[+?One and only one of \b-b\b, \b-c\b, or \b-f\b must be specified.]"
"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \bcut\b "
"cuts from standard input. The start of the file is defined "
"as the current offset.]"
"[b:bytes]:[list?\bcut\b based on a list of byte counts.]"
"[c:characters]:[list?\bcut\b based on a list of character counts.]"
"[d:delimiter]:[delim?The field character for the \b-f\b option is set "
"to \adelim\a. The default is the \btab\b character.]"
"[f:fields]:[list?\bcut\b based on fields separated by the delimiter "
"character specified with the \b-d\b optiion.]"
"[n!:split?Split multibyte characters selected by the \b-b\b option.]"
"[R|r:reclen]#[reclen?If \areclen\a > 0, the input will be read as fixed length "
"records of length \areclen\a when used with the \b-b\b or \b-c\b "
"option.]"
"[s:suppress|only-delimited?Suppress lines with no delimiter characters, "
"when used with the \b-f\b option. By default, lines with no "
"delimiters will be passsed in untouched.]"
"[D:line-delimeter|output-delimiter]:[ldelim?The line delimiter character for "
"the \b-f\b option is set to \aldelim\a. The default is the "
"\bnewline\b character.]"
"[N!:newline?Output new-lines at end of each record when used "
"with the \b-b\b or \b-c\b option.]"
"\n"
"\n[file ...]\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?All files processed successfully.]"
"[+>0?One or more files failed to open or could not be read.]"
"}"
"[+SEE ALSO?\bpaste\b(1), \bgrep\b(1)]";

typedef struct Delim_s {
char *str;
int len;
@@ -534,7 +488,7 @@ int b_cut(int argc, char **argv, Shbltin_t *context) {
wdelim.chr = '\t';
ldelim.chr = '\n';
wdelim.len = ldelim.len = 1;
while ((n = optget(argv, usage))) {
while ((n = optget(argv, sh_optcut))) {
switch (n) { //!OCLINT(MissingDefaultStatement)
case 'b':
case 'c':
Loading