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

Check-in [ed15a9ba9f]
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 | mksh
Files: files | file ages | folders
SHA1: ed15a9ba9ff500ec73977954115e3f930266ebd4
User & Date: vdh 2019-12-28 11:01:31
Context
2019-12-28 11:01
ensure sane input to `sdman'. remove (apparently redundant) use of `eval'. Leaf check-in: ed15a9ba9f user: vdh tags: mksh
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:11
tidy up continued. check-in: 652cbec2de user: vdh tags: mksh
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sd.ksh.

76
77
78
79
80
81
82

83
84
85
86
87
88
89
90
...
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
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
................................................................................
      stacksize=$(sdlinecount "$sdlist")
      mostlen=${#most}
      i=0
      while ((i < indent0+mostlen)); do
         indent+=" "
         ((i++))
      done
      top=$($awk -F'\t' 'NR <= 10 {print $(NF-1) "\t" $NF}' <<< "$sdlist" )
      top=${top//$'\n'/$'\n'$indent}
   } || stacksize=0

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


   report="







>
|







 







|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
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
................................................................................
      stacksize=$(sdlinecount "$sdlist")
      mostlen=${#most}
      i=0
      while ((i < indent0+mostlen)); do
         indent+=" "
         ((i++))
      done
      top=$($awk -F'\t' 'NR <= 10 {print $(NF-1) "\t" $NF}' <<< "$sdlist")
      top=${top//$'\n'/$'\n'$indent}
   } || stacksize=0

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


   report="