-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch b_alias() from optget() to getopt_long()
Another step in switching from the DocOpt base option processing done by the AST `optget()` function to the borg standard `getopt_long()`. It also introduces a system-wide ksh config script to enable auto-loading functions included with ksh by default. This allows the use of the auto-loaded `_ksh_print_help` function. As well as the dirs/popd/pushd set of functions that have been the sole functions included with ksh forever but not automatically enabled. Related #507 Fixes #835
- Loading branch information
1 parent
6ca1c5a
commit d35d42d
Showing
11 changed files
with
126 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# This script is sourced first when the shell starts. It's purpose is to perform basic setup of the | ||
# shell state. For example, where to find autoloaded functions that ship with the shell and arrange | ||
# for them to be loaded on demand. It should not do anything not suitable for every single new ksh | ||
# process. In particular it should be as fast as possible. | ||
# | ||
|
||
# Arrange for standard autoloaded functions to be available. The test for whether or not FPATH is | ||
# already set isn't technically necessary since empty path components are guaranteed not to be | ||
# equivalent to `.` (the CWD). But I prefer to be paranoid since doing so is cheap. | ||
__fpath="${.sh.install_prefix}/share/ksh/functions" | ||
if [[ -z $FPATH ]] | ||
then | ||
FPATH="$__fpath" | ||
else | ||
FPATH="$__fpath:$FPATH" | ||
fi | ||
|
||
for f in "$__fpath"/* | ||
do | ||
typeset -fu $(basename $f) | ||
done | ||
unset __fpath |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Given a ksh man page emit the text of the SYNOPSIS and FLAGS sections and nothing else. This is | ||
# primarily meant to be used by builtins (either special or normal commands) to emit a subset of its | ||
# man page when invoked with `cmd --help` or the argument parsing for the command detects an error. | ||
# Such as via the `builtin_print_help()` function in the ksh source. | ||
# | ||
function _ksh_print_help { | ||
local cmd=$1 | ||
local fname="${.sh.install_prefix}/share/ksh/man/man1/${cmd}.1" | ||
|
||
[[ -f $fname ]] || return 1 # can't find the man page; give up | ||
|
||
# Find the `ul` command to translate x\cHx sequences, etc., into bold chars and such. Pagers | ||
# like `less` do this but better to not rely on them. If `ul` is not available just pipe the | ||
# nroff output unmodified. | ||
local ul=$(whence ul) | ||
[[ -z $ul ]] && ul=cat | ||
|
||
# Try to determine an optimal line length for the output. | ||
local cols=80 | ||
if [[ -t 0 && -t 1 ]] | ||
then | ||
stty size | read _ cols | ||
fi | ||
cols=$(( cols - 4 )) # leave a little space on the right side of the screen | ||
|
||
# Convert the nroff source for the command into something that looks good on the terminal. | ||
# Specifically, by elimating all the text outside of the SYNOPSIS and FLAGS sections while | ||
# attempting to preserve some of the highlighting understood by the terminal. | ||
nroff -c -man -rLL=${cols}n "$fname" | | ||
sed -n \ | ||
-e '/^S.*Y.*N.*O.*P.*S.*I.*S$/,/^[^ ]/ { | ||
/^S/p | ||
/^[^ ]/b | ||
p | ||
}' \ | ||
-e '/^F.*L.*A.*G.*S$/,/^[^ ]/ { | ||
/^F/p | ||
/^[^ ]/b | ||
p | ||
}' | | ||
uniq | "$ul" | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters