I have these function:
#execute vim and then exit on err return
ve() {
vim "$@" || exit
}
export -f ve
#compile c source -> asm source in new tab in xfce terminal
casm() {
[ -z ${1} ] && return
fname=$1
xfce4-terminal --tab -e "bash -c "\""gcc -S $fname.c; ve $fname.s ;exec bash \""
}
export -f casm
In this case, the ve
function ("vim and exit" == "ve"), is called in the second one in double quotes (see here:gcc -S $fname.c; ve $fname.s ;exec bash
). The problem is the bash will give err bash: ve: command not found
(I have export
it afterwards, as you can see), I do not know what else I should do to make it more visible.
For second try, I have tried this:
#compile c source -> asm source in new tab in xfce terminal
casm() {
[ -z ${1} ] && return
fname=$1
xfce4-terminal --tab -e "bash -c "\""gcc -S $fname.c; $(ve $fname.s) ;exec bash \""
}
export -f casm
That is - make the command to be subshell, but then when trying to open it -> Vim: Warning: Output is not to a terminal
, which makes it to crash the terminal. So the question is, how to embed a global function in double quotes and make it safe?
xfce4-terminal
runs. It looks like the function doesn't end up in the inner shell at all. I don't know why xfce4-terminal or anything should clean it out from the environment, but if it was there, you shouldn't get "command not found" for it-e
, consider using-x
instead.bash -c
script).