Skip to content

Instantly share code, notes, and snippets.

@bahamas10
Created March 3, 2015 07:38
Show Gist options
  • Save bahamas10/8212e86ae2aeea46fa3a to your computer and use it in GitHub Desktop.
Save bahamas10/8212e86ae2aeea46fa3a to your computer and use it in GitHub Desktop.
bash quine
#!/usr/bin/env bash
s=(
'#!/usr/bin/env bash'
''
's=('
')'
''
'q=$(printf "\x27")'
'for ((i = 0; i < 3; i++ )); do'
' echo "${s[i]}"'
'done'
'for l in "${s[@]}"; do'
' echo "$q$l$q"'
'done'
'for ((i = 3; i < ${#s[@]}; i++ )); do'
' echo "${s[i]}"'
'done'
)
q=$(printf "\x27")
for ((i = 0; i < 3; i++ )); do
echo "${s[i]}"
done
for l in "${s[@]}"; do
echo "$q$l$q"
done
for ((i = 3; i < ${#s[@]}; i++ )); do
echo "${s[i]}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment