| 1 | #!/usr/bin/env bash |
| 2 | # Desc: Delete symlinks; skips non-symlinks |
| 3 | # Usage: rmsym [paths] |
| 4 | # Version: 0.0.1 |
| 5 | |
| 6 | yell() { echo "$0: $*" >&2; } # print script path and all args to stderr |
| 7 | die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status |
| 8 | must() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails |
| 9 | main () { |
| 10 | # Check args |
| 11 | for psarg in "$@"; do |
| 12 | if [[ -h "$psarg" ]]; then |
| 13 | rm "$psarg"; |
| 14 | else |
| 15 | yell "Not a symbolic link; not deleting:$psarg"; |
| 16 | continue; |
| 17 | fi; |
| 18 | done; |
| 19 | }; # main program |
| 20 | |
| 21 | main "$@"; |
| 22 | |
| 23 | # Author: Steven Baltakatei Sandoval |
| 24 | # License: GPLv3+ |