taskopen icon indicating copy to clipboard operation
taskopen copied to clipboard

Cannot open file with spaces in path [mac]

Open mediapathic opened this issue 2 years ago • 6 comments

If I try to link to a file with spaces, I get an error message clearly splitting the path at the spaces:

The files /Users/mediapathic/vault/02\, /Users/mediapathic/vault/OUTPUT/Stories/02\, /Users/mediapathic/vault/Drafting/Low\, /Users/mediapathic/vault/Tide/low\, and /Users/mediapathic/vault/tide.md do not exist.

This happens if I leave the spaces as is, escape them with backslashes (as in the example above), or enclose the path with either single or double quotes within the task.

mediapathic avatar Feb 20 '23 09:02 mediapathic

try this in your settings:

files.command = "xdg-open \"$FILE\""

artur-shaik avatar Jun 13 '23 16:06 artur-shaik

I spent at least 30 minutes trying every combination of escaping and quotes I could. I could not find a functioning combo. There appears to be some sort of escaping going on which leads to escaping of escaping.

lukebarton avatar May 29 '24 00:05 lukebarton

I do not have a mac for testing but I might be able to help with a few debugging hints:

  • You may run taskopen --debug to show the executed command line.
  • You may also run `taskopen -x'echo $FILE' to output what taskopen grabbed as the file part from the annotation.
  • Taskopen does not do any escaping. It simply grabs what's configured as file.regex, expands a preceding ~ if necessary, and puts the result into $FILE.

On Linux, there are two ways to deal with spaces in file paths for taskopen.

  • You either add the paths to a task's annotation with backslash-escaped spaces
  • or your wrap $FILE in quotes, e.g. files.command = "xdg-open \"$FILE\"".

jschlatow avatar May 29 '24 06:05 jschlatow

The problem is, I believe related to auto-opening with the editnotes command.

I have no reason to believe it is Mac related at this point.

On Wed, 29 May 2024, at 07:44, Johannes Schlatow wrote:

I do not have a mac for testing but I might be able to help with a few debugging hints:

• You may run taskopen --debug to show the executed command line. • You may also run taskopen -x'echo $FILE' to output what taskopen grabbed as the file part from the annotation. • Taskopen does not do any escaping. It simply grabs what's configured as file.regex, expands a preceding ~if necessary, and puts the result into$FILE`. On Linux, there are two ways to deal with spaces in file paths for taskopen.

• You either add the paths to a task's annotation with backslash-escaped spaces • or your wrap $FILE in quotes, e.g. files.command = "xdg-open \"$FILE\"".

— Reply to this email directly, view it on GitHub https://github.com/jschlatow/taskopen/issues/163#issuecomment-2136655463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAYA62P5F6FSPTMH7JRVB3ZEV2N7AVCNFSM6AAAAAAVBTMCICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZWGY2TKNBWGM. You are receiving this because you commented.Message ID: @.***>

lukebarton avatar May 29 '24 07:05 lukebarton

@lukebarton I cannot reproduce the issue with editnotes or ls either. Taskopen passes the command you configured as is to the system shell (basically /bin/sh -c '<command>'). Hence, I'm wondering why -x'ls "$FILE"' or files.command = "ls \"$FILE\"" seems to have any effect.

jschlatow avatar May 29 '24 08:05 jschlatow