From 48d6a9cdb9e9b0d72104ad2eb5214376ed621c19 Mon Sep 17 00:00:00 2001 From: dweller Date: Mon, 18 Mar 2024 05:08:39 +0200 Subject: shellcheck and fix handling of URI encoded file paths --- xpaste | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'xpaste') diff --git a/xpaste b/xpaste index 444206f..77aa842 100755 --- a/xpaste +++ b/xpaste @@ -1,17 +1,17 @@ -#!/bin/sh +#!/bin/sh -e # # Copyright (C) 2023 dwlr # # BSD 3-Clause License (BSD-3-Clause) # See LICENSE for details -set -e - -echo "$(xclip -sel clipboard -o -r -t text/uri-list | cut -d':' -f2- | tr -d '\r')" \ +# NOTE: awk part does URI decoding +xclip -sel clipboard -o -r -t text/uri-list | cut -d':' -f2- | tr -d '\r' \ +| awk -niord '{printf RT?$0chr("0x"substr(RT,2)):$0}' RS=%.. \ | while IFS= read -r path do - if [ -e "${path}" ]; then - cp -v -r "${path}" "$(basename ${path})" + if [ -e "$path" ]; then + cp -v -r "$path" "$(basename "$path")" fi done -- cgit v1.2.3