Skip to content

Commit 4c271cb

Browse files
committed
added working in current directory if no directory argument was given
1 parent 3034475 commit 4c271cb

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

dedup.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
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.
@@ -21,7 +21,7 @@
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
306306
fi
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+
308323
while [[ $# -gt 0 ]]
309324
do
310325
case ${1,,} in

0 commit comments

Comments
 (0)