br shell function does not escape file path
proItheus opened this issue · comments
Broot's wrapping shell function does not escape file path, e.g. test'"$(
, the shell will be crazy.
In regard to how to escape, a stackoverflow post says:
The only quoting method that is safe is ... single quoting of everything (even the empty string, even characters you'd imagine never to be a problem), and represent the single quote character itself as
"'"
or\'
outside of the single-quotes
That is, test'"
as 'test'\''" '
What wrapping are you referring to ? Anything specific ? Can you please describe a complete failing case ?
Ah, sorry for being a bit ambiguous. By wrapping function I mean br
shell function. A failing case:
mkdir \'
br
in shell, and
:focus '
alt+enter
in broot.
What shell are you using ? bash ?
I've tested fish and bash.
Oh, sorry again, that's not the case, the failed case should be '
. Edited previous comment.
This problem can now (>1.33.1
) be avoided by using the following verb:
{
key: alt-enter
invocation: cd
cmd: ":write_output {directory};:quit"
}
with the following launcher function (Bash) (only slightly tested):
function br {
local path path_file code
path_file=$(mktemp)
if broot --verb-output "$path_file" "$@"; then
path=$(<"$path_file")
command rm -f "$path_file"
if [[ -d "$path" ]]; then
cd "$path"
fi
else
code=$?
command rm -f "$path_file"
return "$code"
fi
}