aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-02-04 19:54:54 -0200
committerSilvio Rhatto <rhatto@riseup.net>2019-02-04 19:54:54 -0200
commit86b391cbde896ce932fbc40b6083dcacbd04fa14 (patch)
tree727be45030efaeb8fd555a2ecb233d7b393e27ea
parent72cc135192cc679cc45dc4b014907af1304e62ce (diff)
downloadutils-x11-86b391cbde896ce932fbc40b6083dcacbd04fa14.tar.gz
utils-x11-86b391cbde896ce932fbc40b6083dcacbd04fa14.tar.bz2
Fix spoolpaste symlinking
-rwxr-xr-xspoolpaste15
1 files changed, 11 insertions, 4 deletions
diff --git a/spoolpaste b/spoolpaste
index 74a4c77..48b6dfd 100755
--- a/spoolpaste
+++ b/spoolpaste
@@ -9,8 +9,15 @@ BASENAME="`basename $0`"
SPOOL="$HOME/temp/log/spool.md"
if [ ! -z "$1" ]; then
- mkdir -p "`dirname $*`"
- touch "$*"
+ # Ensure dest file exists
+ if [ ! -e "$*" ]; then
+ mkdir -p "`dirname $*`"
+ touch "$*"
+ fi
+
+ # Get absolute filename
+ DIR="$(cd `dirname $*` > /dev/null && pwd)"
+ FILE="$DIR/`basename $*`"
# Set current spool file
#if [ -e "$SPOOL" ] && [ "`wc -l $SPOOL`" != "0" ]; then
@@ -19,9 +26,9 @@ if [ ! -z "$1" ]; then
exit 1
fi
- rm -f $SPOOL && ln -s "$*" $SPOOL
+ rm -f $SPOOL && ln -s "$FILE" $SPOOL
- echo Set $SPOOL to "$*"
+ echo Set $SPOOL to "$FILE"
else
echo -e "\n\n [...]\n" >> $SPOOL
xclip -o | sed -e 's/^\([^ ]\)/ \1/' >> $SPOOL