Skip to content

Instantly share code, notes, and snippets.

@bahamat
Forked from bahamas10/quine.bash
Last active August 29, 2015 14:19
Show Gist options
  • Save bahamat/85ad641bdf0a3fdba9da to your computer and use it in GitHub Desktop.
Save bahamat/85ad641bdf0a3fdba9da to your computer and use it in GitHub Desktop.
#!/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