Попробуйте открыть его, запустив в терминале (Ctrl+Alt+T):
/opt/VSCode-linux-x64/Code
Если он работает, вы можете сделать ярлык (таким образом, чтобы открыть код, вам нужно только запустить код
):
sudo ln -s /opt/VSCode-linux-x64/Code /usr/local/bin/code
run_my_command() {
#...
if [[... ]]; then
tmpfile=$(mktemp)
trap 'rm -f "$tmpfile"' RETURN
other_cmd >"$tmpfile"
FILEFLAG='--input_file'
FILEARG="$tmpfile"
else
FILEARG=''
fi
my_command $FILEFLAG $FILEARG \
...
return
}
... o algo por el estilo.
Es decir, use un archivo temporal en lugar de intentar usar una sustitución de proceso.
Así es como puede usar eval
para obtener lo que desea:
run_my_command() {
# Get ARG1, ARG2, ARG3...
commandline="my_command $ARG1FLAGS $ARG2FLAGS $ARG3FLAGS"
if [[... ]]; then
commandline="$commandline --input_file <(other_cmd)"
fi
eval $commandline
}
Esto es más como eludir el problema, pero hay menos duplicación (de$ARGnFLAGS
)si coloca los otros argumentos en una matriz en lugar de variables individuales.
También es lo correcto en cualquier caso, ya que puede obtener los argumentos del comando sin que se interpongan divisiones de palabras o nombres de archivos.
run_my_command() {
args=()
if [[... ]]; then
args+=(--arg1 "$ARG1")
fi
if [[... ]]; then
args+=(--arg2 "$ARG2")
fi
if [[... ]]; then
my_command --input_file <(other_cmd) "${args[@]}"
else
my_command "${args[@]}"
fi
}