Skip to content

Instantly share code, notes, and snippets.

@marc0der
Last active May 24, 2022 10:06
Show Gist options
  • Save marc0der/6015948 to your computer and use it in GitHub Desktop.
Save marc0der/6015948 to your computer and use it in GitHub Desktop.
Higher order function in bash!
#!/bin/bash
function printit {
echo "This is from an embedded function: $1"
}
function printthat {
echo "This is the first line."
$1 $2
echo "This is the third line."
}
printthat printit 1
@eliasdorneles
Copy link

yeah, that's cool!
bash can do a lot worse though. :)
I've seen code that evals code that evals code in a build script -- that wasn't cool anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment