sd -- a drop-in replacement for `cd'

Check-in [62858ad55b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:ensure sane input to `sdman'. remove (apparently redundant) use of `eval'.
Timelines: family | ancestors | ksh
Files: files | file ages | folders
SHA1: 62858ad55b345874881c78fea82052adfc0f7896
User & Date: vdh 2019-12-28 11:01:13
Context
2019-12-28 11:01
ensure sane input to `sdman'. remove (apparently redundant) use of `eval'. Leaf check-in: 62858ad55b user: vdh tags: ksh
2019-12-28 10:58
ensure sane input to `sdman'. remove (apparently redundant) use of `eval'. check-in: 5b18ec4ca0 user: vdh tags: trunk
2019-12-22 17:13
take over the tidy up from mksh branch. check-in: a28d3150c6 user: vdh tags: ksh
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sd.ksh.

74
75
76
77
78
79
80

81
82
83
84
85
86
87
88
...
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
sdshellcheck || { unset -f sdshellcheck; return 1; }


function sdman {  ## formatter
#---------------
#an inline manpage. `formatter' should be `[ng]roff -man'.
if [[ $# == 0 ]]; then set nroff -man; fi

cat <<-HERE | eval $* | less -R
.\"----------------------------------------------------------
.TH SD 1 "13. March 2016"
.nh
.SH NAME
sd \- switch between directories using a dynamic directory stack
.SH SYNOPSIS
.SY sd
................................................................................
   lines=$(sdlinecount "$sdlog")

   most="top ten on stack :"
   ((lines > 0)) && {
      stacksize=$(sdlinecount "$sdlist")
      mostlen=${#most}
      for ((i=1; i<= indent0+mostlen; i++)); do indent+=" "; done
      top=$($awk -F'\t' 'NR <= 10 {print $(NF-1) "\t" $NF}' <<< "$sdlist" )
      top=${top//$'\n'/$'\n'$indent}
   } || stacksize=0

   vdir=${dirv/#$HOME/\~}


   report="







>
|







 







|







74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
sdshellcheck || { unset -f sdshellcheck; return 1; }


function sdman {  ## formatter
#---------------
#an inline manpage. `formatter' should be `[ng]roff -man'.
if [[ $# == 0 ]]; then set nroff -man; fi
[[ $* == [ng]roff\ -man ]] || return   # be paranoid: ensure benign content of $*
cat <<-HERE | $* | less -R
.\"----------------------------------------------------------
.TH SD 1 "13. March 2016"
.nh
.SH NAME
sd \- switch between directories using a dynamic directory stack
.SH SYNOPSIS
.SY sd
................................................................................
   lines=$(sdlinecount "$sdlog")

   most="top ten on stack :"
   ((lines > 0)) && {
      stacksize=$(sdlinecount "$sdlist")
      mostlen=${#most}
      for ((i=1; i<= indent0+mostlen; i++)); do indent+=" "; done
      top=$($awk -F'\t' 'NR <= 10 {print $(NF-1) "\t" $NF}' <<< "$sdlist")
      top=${top//$'\n'/$'\n'$indent}
   } || stacksize=0

   vdir=${dirv/#$HOME/\~}


   report="