Skip to content

Commit 3a4783f

Browse files
committed
subcmd and dash fixes
1 parent 20fe6d8 commit 3a4783f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

junonia

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ _junonia_md2spec () {
772772
'
773773

774774
awk -v wrap="$JUNONIA_WRAP" -v col1="$JUNONIA_COL1" \
775-
-v col2="$JUNONIA_COL2" -v cmd="$1" \
775+
-v col2="$JUNONIA_COL2" \
776776
"$JUNONIA_AWKS $awk_prog" "$@"
777777
}
778778

@@ -820,7 +820,9 @@ _junonia_md2help () {
820820
# If help docs have started, this signals the end of processing the
821821
# non-subcommand documentation.
822822
if(cmd_doc_start) {
823+
cmd_doc_start = 0
823824
cmd_doc_end = 1
825+
echodebug("end command documentation")
824826
}
825827
826828
# Extract the commands, subcommands, and aliases in this header
@@ -855,6 +857,7 @@ _junonia_md2help () {
855857
if(n == 1) {
856858
txt = txt " " cmd_part "\n"
857859
cmd_doc_start = 1
860+
echodebug("start command documentation")
858861
}
859862
860863
next
@@ -883,10 +886,11 @@ _junonia_md2help () {
883886
# Get the last primary subcommand (not the aliases) and build a regex to
884887
# find this commands subcommands to document.
885888
split($0, subcmda, ",")
886-
subcmd_re = "^" subcmda[1] " [-_A-Za-z0-9]+(,|$)"
889+
subcmd_re = "^" subcmda[1] " [-_A-Za-z0-9]+"
887890
echodebug(" subcmd regex: " subcmd_re)
888891
889892
cmd_doc_start = 1
893+
echodebug("start command documentation")
890894
i++
891895
next
892896
}
@@ -1387,7 +1391,7 @@ _junonia_cache () {
13871391
fi
13881392

13891393
if [ $clear ]; then
1390-
if ! cachedir_abspath="$((cd "$JUNONIA_CACHEDIR" &&
1394+
if ! cachedir_abspath="$( (cd "$JUNONIA_CACHEDIR" &&
13911395
pwd -P) 2>/dev/null)"; then
13921396
echoerr "unable to clear cache. could not enter directory:"
13931397
echoerr "$JUNONIA_CACHEDIR"
@@ -1766,7 +1770,7 @@ junonia_init () {
17661770
JUNONIA_COL1="${JUNONIA_COL1:-18}"
17671771
JUNONIA_COL2="${JUNONIA_COL2:-60}"
17681772

1769-
readonly JUNONIA_VERSION="1.0.3"
1773+
readonly JUNONIA_VERSION="1.0.4"
17701774

17711775
# Information Separator control characters (IS4 - IS1)
17721776
readonly JUNONIA_FS="" # File Separator (FS / IS4 / dec 28)
@@ -2509,7 +2513,7 @@ _junonia_run_final () {
25092513
#print s
25102514
}
25112515
}
2512-
' "$_junonia_cmds"
2516+
' "$_junonia_cmds" -
25132517
)"
25142518

25152519
echodebug "$spec"
@@ -2547,12 +2551,16 @@ _junonia_exec () {
25472551

25482552
filter_func="$1"
25492553
shift
2554+
25502555
md="$1"
25512556
shift
2557+
25522558
spec_type="$1"
25532559
shift
2560+
25542561
spec="$1"
25552562
shift
2563+
25562564
func="$1"
25572565
shift
25582566

@@ -2593,8 +2601,9 @@ _junonia_exec () {
25932601
# The filter function might indicate via its return value, or the meta filter
25942602
# by looking at the spec, that we should shift off some common (and possibly
25952603
# other) values.
2604+
echodebug "Shifting $shift_n arguments"
25962605
i=0
2597-
while [ $i -lt $shift_n ]; do
2606+
while [ $i -lt $# ] && [ $i -lt $shift_n ]; do
25982607
shift
25992608
i=$(( $i + 1 ))
26002609
done

0 commit comments

Comments
 (0)