|
|
|
|
|
by mhitza
1968 days ago
|
|
I think the reason no one uses shell for anything more complicated is related to the fact that: 1. It's not generally taught in CS classes, and people just search up enough syntax to be able to acomplish their task. 2. A lot of it's variable expansion/substitution are remiscient of Perl. 3. Small mistakes can have huge impact (everyone knows how often rm -rf of unintended directories takes place). Just for the fun of it, I suggest everybody reads at least once the Unix Haters Handbook https://web.mit.edu/~simsong/www/ugh.pdf If I understood your task correctly, it can be done just nicely in the shell (after all, this is what I think the shell excels at). You'll see the unpleasant side of it when dealing with function arguments and slicing values and referecing specific ones. I don't guarantee it does what you want to the letter, but just my quick interpetration of your description. function demo() {
first=$1
last="${!#}"
$first &
wait
for f in "${@:2:$#-2}"; do
$f &
done
wait
$last
}
function first() {
sleep 5
}
function pingy() {
ping -c 8 google.com
}
function last() {
echo -----------------------------
echo done
}
function inception() {
demo first pingy pingy
}
demo first pingy pingy inception last
|
|