Sublime Forum

File name with spaces from CLI

#1

suppose i do have a file name like that :
“path/to/11-12-21–06-34–apt-get install converseen.txt”

it is in a shell variable, say, $DATEDFILE.

if i do :

touch "${DATEDFILE}"

i get the correct file at the right place, howver doing :

/usr/bin/sublime-text-2 "${DATEDFILE}"

opened 3 files :

path/to/11-12-21–06-34–apt-get
install
and
converseen.txt

how do I protect spaces for ST2 ???

0 Likes

#2

It looks like you’re using a shell script that doesn’t quote the arguments correctly. Just use a symlink instead.

0 Likes

#3

I don’t think so because I’ve changed my script to launch Gedit instead of ST2 and it works, here is my code :

#!/usr/bin/zsh
DATE=`date '+%y-%m-%d--%H-%M--'`

if  ${1} != '' ]]; then
	DATEDFILE="${HOME}/Installations/${DATE}${1}.txt"
	touch "${DATEDFILE}"
	#/usr/bin/sublime-text-2 "${DATEDFILE}"
	/usr/bin/gedit "${DATEDFILE}"
else
	echo -n "${DATE}" | xclip -selection c
	echo "'${DATE}' copied to the clipboard."
fi

exit 0
0 Likes

#4

I suspect /usr/bin/sublime-text-2 is the culprit: check to see if it’s a shell script

0 Likes

#5

BINGO!
U’re right :

$ cat  /usr/bin/sublime-text-2
#!/bin/bash
/usr/lib/sublime-text-2/sublime_text $*

then I’ve changed my script accordingly.
thanks a lot!!!

0 Likes