Minor order of operations changes and var name consistency (lower-case)
This commit is contained in:
parent
03303c9e36
commit
434a50987e
9 changed files with 236 additions and 208 deletions
28
sw
28
sw
|
|
@ -1,23 +1,23 @@
|
|||
#!/bin/sh
|
||||
# It just swaps two files
|
||||
|
||||
export DAISY_INTERNAL=1
|
||||
export DAISY_INTERNAL1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
FILE1=$1
|
||||
FILE2=$2
|
||||
file1=$1
|
||||
file2=$2
|
||||
|
||||
function helpFn()
|
||||
{
|
||||
ERROR=$?
|
||||
if [[ $ERROR -gt 0 ]];
|
||||
error=$?
|
||||
if [[ $error -gt 0 ]];
|
||||
then
|
||||
ERROR_TEXT=$(perl -E 'say $!=shift' $ERROR)
|
||||
echo "$DAISY_BIN error ($ERROR): $ERROR_TEXT"
|
||||
error_text=$(perl -E 'say $!=shift' $error)
|
||||
echo "$DAISY_BIN error ($error): $error_text"
|
||||
fi
|
||||
echo "Usage: $DAISY_BIN <file1> <file2>"
|
||||
echo Swap two files in a filesystem.
|
||||
exit $ERROR
|
||||
exit $error
|
||||
}
|
||||
|
||||
if [[ $@ == *"--help"* ]];
|
||||
|
|
@ -36,14 +36,14 @@ trap helpFn ERR
|
|||
|
||||
# We want to swap two files
|
||||
# Easy, but let's be safe about it
|
||||
ls "$FILE1" >/dev/null
|
||||
ls "$FILE2" >/dev/null
|
||||
ls "$file1" >/dev/null
|
||||
ls "$file2" >/dev/null
|
||||
|
||||
# Files should exist, now we move
|
||||
mv "$FILE1" "$FILE1.sw"
|
||||
mv "$FILE2" "$FILE2.sw"
|
||||
mv "$file1" "$file1.sw"
|
||||
mv "$file2" "$file2.sw"
|
||||
|
||||
# We got our moved copies, now we simply rename
|
||||
mv "$FILE1.sw" "$FILE2"
|
||||
mv "$FILE2.sw" "$FILE1"
|
||||
mv "$file1.sw" "$file2"
|
||||
mv "$file2.sw" "$file1"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue