- local help="lnf [--help] LN_ARGUMENTS...
-Create symlinks conveniently.
-Remove existing file/links using trash-put or rm -rf if it is not available.
-Create directory if needed. Finally, ln -s -- LN_ARGUMENTS"
- if [[ $1 == --help ]]; then
+ local help="Usage:
+ lnf [OPTIONS] -T TARGET LINK_NAME (1st form)
+ lnf [OPTIONS] TARGET (2nd form)
+ lnf [OPTIONS] TARGET... DIRECTORY (3rd form)
+Create symlinks forcefully
+
+If the link already exists, make it's ownership be the same as if it was
+newly created (only chown if we are root). Removes existing files using
+trash-put or rm -rf if it is not available, or if trash-put fails due to a
+limitation such as a cross-filesystem link. Create directory of link if
+needed. Slightly more restrictive arguments than ln.
+
+In the 1st form, create a link to TARGET with the name LINK_NAME. In the 2nd
+form, create a link to TARGET in the current directory. In the 3rd form, create
+links to each TARGET in DIRECTORY.
+
+-n|--dry-run Do verbose dry run.
+-v|--verbose Print commands which modify the filesystem.
+-h|--help Print help and exit.
+"
+
+
+ local temp
+ local verbose=false
+ local dry_run=false
+ local nodir
+ temp=$(getopt -l help,dry-run,verbose hnTv "$@") || usage 1
+ eval set -- "$temp"
+ while true; do
+ case $1 in
+ -n|--dry-run) dry_run=true; verbose=true; shift ;;
+ -T) nodir=-T; shift ;;
+ -v|--verbose) verbose=true; shift ;;
+ -h|--help) echo "$help"; return 0 ;;
+ --) shift; break ;;
+ *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
+ esac
+ done
+
+ if (( $# == 0 )); then