From 0c2f45e2f263f918f39d16acb4e4ed5af52e5d94 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Tue, 9 Jan 2024 11:31:38 +0100 Subject: [PATCH] fix trash-put failing on space in filename --- .local/bin/trash-put | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.local/bin/trash-put b/.local/bin/trash-put index c2a47e71..9dde3850 100755 --- a/.local/bin/trash-put +++ b/.local/bin/trash-put @@ -7,16 +7,16 @@ use File::Path("make_path"); use List::Util("max"); sub fs_root ($file_name) { - chomp( my $ret = `stat -c %m $file_name` ); + chomp( my $ret = `stat -c %m "$file_name"` ); return $ret; } sub file_info ($file) { - my $file_name = `basename $file`; - my $file_path = `realpath -s $file`; + my $file_name = `basename "$file"`; + my $file_path = `realpath -s "$file"`; + chomp( $file_name, $file_path ); my $file_fs_root = fs_root($file_name); - chomp( $file_name, $file_path, $file_fs_root ); return ( $file_name, $file_path, $file_fs_root ); } @@ -58,6 +58,7 @@ if ( $#ARGV + 1 != 1 ) { stat $ARGV[0] or die "$!\n"; my ( $file_name, $file_src, $file_fs_root ) = file_info( $ARGV[0] ); + my ( $trash_info_path, $trash_file_path ) = trash_dirs($file_fs_root); my $target_name = target_file_name( $file_name, $trash_file_path ); chomp( my $deletion_time = `date -u +%Y%m%dUTC%T` );