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