File: cdadd

package info (click to toggle)
cdtool 2.1.8-release-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 772 kB
  • sloc: ansic: 4,886; sh: 2,823; makefile: 143
file content (62 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
# "cdadd" copyright 1994 thomas insel
#         copyright 1996 sven oliver moll
#         copyright 2004 Max Vozeler
usage()
{
  echo >&2 Usage: `basename $0` [-[0-7]]
  echo >&2 This program is part of cdtool. See \"man cdtool\" for more info.
  exit 1
}

PATH=/bin:/usr/bin:/usr/local/bin
TMPFILE=~/.cdadd-$$

case $# in
  [01]) ;;
  *) usage;;
esac

case x$1 in
  x-[0-7]) DRIVE=-$1;;
  x) ;;
  *) usage;;
esac

cdir $DRIVE -t > $TMPFILE

if test -z $EDITOR; then
  for favourite in emacs vim vi; do
    if command -v $favourite >/dev/null 2>&1; then
      EDITOR=$favourite
      break
    fi
  done
fi

if test -z $EDITOR; then
  echo Unable to find an editor. Please set the environment variable
  echo EDITOR to the location of your preferred editor. Eg:
  echo
  echo   \$ export EDITOR=/path/to/editor
  echo   \$ cdadd
  echo
  exit 1
fi

$EDITOR $TMPFILE

echo ==== about to add =================
cat $TMPFILE
echo -n ==== ok? [Yn]
read n;
case $n in
  [nN])
    echo aborting.
    exit 1
    ;;
esac

cat $TMPFILE >>~/.cdtooldb
rm $TMPFILE