fishmarks icon indicating copy to clipboard operation
fishmarks copied to clipboard

`sed` errors out when deleting a bookmark on MacOS

Open ankur-gupta opened this issue 3 years ago • 1 comments

I've been using fishmarks for a long time. Recently, I noticed that deleting a bookmark errors out due to sed. Here's how this looks like:

ankur@MauiCovenant ~/L/A/S/P/User> s st3user
ankur@MauiCovenant ~/L/A/S/P/User> l
st3user              /Users/ankur/Library/Application Support/Sublime Text/Packages/User
ankur@MauiCovenant ~/L/A/S/P/User> d st3user
sed: illegal option -- -
usage: sed script [-Ealnru] [-i extension] [file ...]
	sed [-Ealnu] [-i extension] [-e script] ... [-f script_file] ... [file ...]

I notice that the error is due to this line in fishmarks/marks.fish's delete_bookmark function:

sed --follow-symlinks -i='' "/DIR_$argv[1]=/d" $SDIRS

The error exists if I reorder the --follow-symlinks option:

sed -i='' --follow-symlinks "/DIR_$argv[1]=/d" $SDIRS

But, error disappears when I change the above line to

sed -i --follow-symlinks "/DIR_$argv[1]=/d" $SDIRS

I see that -i='' was added in #1. I don't know if -i='' is still needed. I did a test on MacOS and it seems that a fishmark associated with a relocated folder can still be deleted with only -i --follow-symlinks without needing =''. Let me know what you think. Thanks!

ankur-gupta avatar Feb 19 '22 19:02 ankur-gupta

I'm getting this too (macOS 13.1) - I think the problem is that --follow-symlinks only works for GNU sed, not the BSD version that macs come with (in /usr/bin).

So, based on what the command is supposed to do, I got mine to work by changing the line to:

sed -i='' "/DIR_$argv[1]=/d" (realpath $SDIRS)

avirshup avatar Dec 23 '22 21:12 avirshup