launch bash without using any letters

"$(- 2>&1)";${_%%:*}
I don't know why anyone would use this, I was just messing around tonight and managed to start bash without using any letters and thought I would share. It's pretty simple, first it tries to execute "-" redirecting stderr to stdout which prints the error "bash: -: command not found" to standard output, then I try to execute "bash: -: command not found" which produces the output "bash: bash: -: command not found: command not found". lastly, (on the other side of the semicolon) I use the underscore environment variable which refers to the last command run ("bash: -: command not found") and take out everything after the first ":" character using brace expressions and your left with "bash"
Sample Output
seth@Laptop:~/Code/deb/tmp$ "$(- 2>&1)";${_%%:*}
bash: bash: -: command not found: command not found
seth@Laptop:~/Code/deb/tmp$ exit
exit
seth@Laptop:~/Code/deb/tmp$ 

6
By: LinuxMan
2012-12-29 09:21:09

2 Alternatives + Submit Alt

What Others Think

Curious, but hardly useful, as you need to be in bash. Why would yo need to exec a subshell?
netizen · 284 weeks and 6 days ago
this doesn't really have a purpose, but it opens the possibility of writing entire scripts without using letters, similar to what was done in this article with javascript: http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html also, you are right, i don't need the subshell around the ${}, I'll fix that right away
LinuxMan · 284 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: