Today I encountered something quite strange
I have two scripts:
wrong.sh:
execute()
{
${@}
}
execute "ls -l | less"
right.sh:
execute()
{
${@}
}
execute ls -l | less
Running sh wrong.sh gives the following output:
ls: less: No such file or directory
ls: |: No such file or directory
While running sh right.sh gives me the same thing as running ls -l | less
May I know:
(1) While running sh wrong.sh will give me that wrong output
(2) How to modify the execute function so that running sh wrong.sh will gives me the same thing as running ls -l | less
$@like this"$@"and don't quote the whole argument because the function will search for a literal"ls -l | less"which is a whole string but there is more to it than you're telling us, kindly give the real problem that you're trying to solve.