44#
55# FILE: dedup.sh
66#
7- # USAGE: dedup.sh [OPTION]... DIRECTORY...
7+ # USAGE: dedup.sh [OPTION]... [ DIRECTORY] ...
88#
99# DESCRIPTION: Script for deduplicate of files and replace them with hardlinks.
10- # The default starting directory is the current directory.
10+ # The default directory is the current directory.
1111# Don’t work across filesystems.
1212#
1313# OPTIONS: See function ’usage’ below.
2121#
2222# AUTHOR: Andreas Klamke
2323#
24- # VERSION: 1.1.4
24+ # VERSION: 1.1.5
2525#
2626# CREATED: 12.12.2015
2727#
@@ -46,7 +46,7 @@ function usage {
4646
4747 # print usage manual
4848 echo -e "
49- \rUsage: $script_name [OPTION]... DIRECTORY...
49+ \rUsage: $script_name [OPTION]... [ DIRECTORY] ...
5050 \rDeduplicate files and replace duplicates with hardlinks.
5151
5252 \rMandatory arguments to long options are mandatory for short options too.
@@ -58,7 +58,7 @@ function usage {
5858 \r -h, --help display this help and exit
5959 \r -v, --verbose more details in output
6060
61- \rIf DIRECTORY is '-' or missing, current directory is used.
61+ \rIf DIRECTORY is missing, current directory is used.
6262 \rExit status is 0 if no error occures, otherwise exit status is 1.
6363
6464 \rReport bugs on: https://github.com/FlatKey/dedup
@@ -305,6 +305,21 @@ then
305305 exit 1
306306fi
307307
308+ # test if a directory argument exist
309+ for argument in $@
310+ do
311+ if [[ ! $argument == " -" * ]]
312+ then
313+ directory_argument_exists=1
314+ fi
315+ done
316+
317+ # set current directory if no directory argument exist
318+ if [[ ! $directory_argument_exists -eq 1 ]]
319+ then
320+ set -- " $@ " " $( pwd) "
321+ fi
322+
308323while [[ $# -gt 0 ]]
309324do
310325 case ${1,,} in
0 commit comments