| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # "cdadd" copyright 1994 thomas insel |
| 3 | # copyright 1996 sven oliver moll |
| 4 | # copyright 2004 Max Vozeler |
| 5 | usagescip-shell shell cdtool 2.1.8-release-9 usage().() |
| 6 | { |
| 7 | echoscip-shell system . . echo. >&2 Usage: `basenamescip-shell system . . basename. $0` [-[0-7]] |
| 8 | echoscip-shell system . . echo. >&2 This program is part of cdtool. See \"man cdtool\" for more info. |
| 9 | exit 1 |
| 10 | } |
| 11 | |
| 12 | PATH=/bin:/usr/bin:/usr/local/binscip-shell filesystem . . `/bin:/usr/bin:/usr/local/bin`. |
| 13 | TMPFILE=~/.cdadd-$$ |
| 14 | |
| 15 | case $# in |
| 16 | [01]) ;; |
| 17 | *) usagescip-shell shell cdtool 2.1.8-release-9 usage().;; |
| 18 | esac |
| 19 | |
| 20 | case x$1 in |
| 21 | x-[0-7]) DRIVE=-$1;; |
| 22 | x) ;; |
| 23 | *) usagescip-shell shell cdtool 2.1.8-release-9 usage().;; |
| 24 | esac |
| 25 | |
| 26 | cdir $DRIVE -t > $TMPFILE |
| 27 | |
| 28 | if testscip-shell system . . test. -z $EDITOR; then |
| 29 | for favourite in emacs vim vi; do |
| 30 | if command -v $favourite >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then |
| 31 | EDITOR=$favourite |
| 32 | break |
| 33 | fi |
| 34 | done |
| 35 | fi |
| 36 | |
| 37 | if testscip-shell system . . test. -z $EDITOR; then |
| 38 | echoscip-shell system . . echo. Unable to find an editor. Please set the environment variable |
| 39 | echoscip-shell system . . echo. EDITOR to the location of your preferred editor. Eg: |
| 40 | echoscip-shell system . . echo. |
| 41 | echoscip-shell system . . echo. \$ export EDITOR=/path/to/editorscip-shell filesystem . . `/path/to/editor`. |
| 42 | echoscip-shell system . . echo. \$ cdadd |
| 43 | echoscip-shell system . . echo. |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
| 47 | $EDITOR $TMPFILE |
| 48 | |
| 49 | echoscip-shell system . . echo. ==== about to add ================= |
| 50 | catscip-shell system . . cat. $TMPFILE |
| 51 | echoscip-shell system . . echo. -n ==== ok? [Yn] |
| 52 | read n; |
| 53 | case $n in |
| 54 | [nN]) |
| 55 | echoscip-shell system . . echo. aborting. |
| 56 | exit 1 |
| 57 | ;; |
| 58 | esac |
| 59 | |
| 60 | catscip-shell system . . cat. $TMPFILE >>~/.cdtooldb |
| 61 | rmscip-shell system . . rm. $TMPFILE |
| 62 |