lackadaisical/sw
Sam Hardeman ab730db2f7 Major chhanges: daisy.source renamed to ld.source.
All files have been prettified by making sure we use 2-space indent.

agenda:
Instead of the hidden .tree file, a file created "More..." is made.
You can use (ex) "agenda --view "2026" to get a full list of files from that
year/date/day.
Additionally, minor fixes have been made.

clip:
You can now use "-c" to clear the clipbaord.
2026-05-05 15:42:34 +02:00

49 lines
939 B
Bash
Executable file

#!/usr/bin/env bash
# It just swaps two files
LD_INTERNAL1
. $(dirname $(realpath $0))/ld.source
file1=$1
file2=$2
function helpFn()
{
error=$?
if [[ $error -gt 0 ]];
then
error_text=$(perl -E 'say $!=shift' $error)
echo "$LD_BIN error ($error): $error_text"
fi
echo "Usage: $LD_BIN <file1> <file2>"
echo Swap two files in a filesystem.
exit $error
}
if [[ $@ == *"--help"* ]];
then
helpFn
elif [[ $@ == '' ]];
then
echo "No arguments specified."
helpFn
fi
# We set a trap here, together with 'set -e' above,
# this makes sure we exit gracefully if we have an
# error in one of the ls or mv calls.
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
# Files should exist, now we move
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"