distrobox
distrobox copied to clipboard
Getting around `eval` in the various scripts
Hi
first of all, thanks for the project. It looks like it can save me a lot of time maintaining my containerized commands :+1:
I was curious, so I had a look at the scripts. I am wondering: in the generated code from a distrobox-export
you are quoting the arguments to run the command with eval
when outside of the container. But why not just run the command directly ?
exec /usr/local/bin/distrobox-enter -n <whatever> -- /usr/bin/<whatever> "%@"
A way to avoid eval when constructing command lines
When constructing arguments, you could use set --
to avoid lot of quoting. This example runs its arguments with the '-l' option through the ls
command:
#! /bin/sh -x
[ $# -eq 0 ] && echo "usage: $0 <filename>..." && exit 1
# build from back to front
ls_args="-l -d"
set -- ${ls_args} "$@"
set -- ls "$@"
"$@"