top | item 13989215

Explain Shell

775 points| aleem | 9 years ago |explainshell.com | reply

85 comments

order
[+] sjrd|9 years ago|reply
Very nice! I fed it one of my favorite commands:

    git branch --merged | grep -v master | xargs -n 1 git branch -d
and it dealt with it reasonably well. The only part it couldn't understand was `branch -d` at the end. In other words, it was not capable of recognizing that the non-option arguments to `xargs` should actually be recursively interpreted as a command-line.
[+] tsneed290|9 years ago|reply
TIL that git calls itself "the stupid content tracker"
[+] bradbeattie|9 years ago|reply
I fed it the most recent command posted on commandlinefu.com:

    grep -i s2enc /etc/vcac/server.xml | sed -e 's/.* password=\"\([^\"]*\)\".*/\1/' | xargs -n 1 vcac-config prop-util -d --p 2>/dev/null; echo
Given the height of the result, scrolling up and down became a real pain. Maybe collapsable sections or position:fixed for the command or something like that?
[+] IE6|9 years ago|reply
The "navigate:" part lets you cycle through 'chunks' of explanations
[+] dang|9 years ago|reply
[+] idank|9 years ago|reply
Wow it's been 4 years?

Would you believe it if I told you it's running on the smallest digital ocean instance, backed by MongoDB (!), and the only time I had to do any maintenance on it was when DO turned down the machine I happened to run on? The service doesn't exactly scream complexity, but it's nice when you put something out there and it just runs!

[+] The_Hoff|9 years ago|reply
I would love it if the site was encrypted so that I could input raw commands at work without modifying sensitive information. (Yes I understand the host can still record this sensitive information, and no I have not looked through the source code yet to see that this doesn't occur).
[+] boramalper|9 years ago|reply
> and no I have not looked through the source code yet to see that this doesn't occur

Still, the website might be running on a modified version.

[+] Ajedi32|9 years ago|reply
Well, it's open-source so I guess you could always self-host.
[+] dwpdwpdwpdwpdwp|9 years ago|reply
Quite Nice. Just FYI, the very first command, :(){ :|:& };: is a fork bomb and you probably shouldn't run it in your shell
[+] mih|9 years ago|reply
Wish I'd read your comment beforehand. Tried it blindly and and lost about 10 min trying to figure out what was happening ...
[+] dullgiulio|9 years ago|reply
Which is easily blocked by having sensible ulimits. Too bad they are always at zero (no limits.)
[+] tmerr|9 years ago|reply
This works well, but the web interface seems like an unnecessary layer on top of what could just be a terminal based tool. I'm trying to resist the urge to fork this, putting another project on my todo list I will never finish
[+] tomjakubowski|9 years ago|reply
The lines connecting each explanation to the relevant part of the command line could be tricky to squeeze into a terminal window. You'd could instead create an interface with a movable "cursor", which highlights a single "chunk" of the command line, and presents the explanation for that "chunk" beneath the entire command line string.
[+] LostCharacter|9 years ago|reply
I have a little bash script I picked up somewhere that uses mankier.com to a similar effect:

  explain () {
      if [ "$#" -eq 0 ]
      then
          while read -p "Command: " cmd
          do
              curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd"
          done
          echo "Bye!"
      elif [ "$#" -eq 1 ]
      then
          curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1"
      else
          echo "Usage"
          echo "explain                  interactive mode."
          echo "explain 'cmd -o | ...'   one quoted command to explain it."
      fi
  }
[+] fbis251|9 years ago|reply
Does anyone know where I can find a completely offline tool that does what this site does?

The source for this seems like a bit of overkill. I'd like to be able to use a cli based tool that shows me relevant man sections for the flags I chose for example

[+] TeMPOraL|9 years ago|reply
Lovely! Bookmarking for future use!

Some quick notes on my way back from work:

1. Broken on mobile :(. Default layout is a mess, and "request desktop site" has the lines going to the edge of the screen, making them invisible. S7, Android, Firefox.

2. Totally neeeds to be done as an Emacs mode (preferably offline). Both for checking a particular command and during writing shell scripts.

[+] btschaegg|9 years ago|reply
Very impressive.

It seems to rely strongly on common *NIX CLI patterns though. It really doesn't like dd, for example[1].

[1]: http://explainshell.com/explain?cmd=dd+if%3D%2Fdev%2Fsda+of%...

Edit:

Also, it doesn't understand that the token after `-p` for netcat is actually the port argument[2]. I guess it is parsing manpages internally?

[2]: http://explainshell.com/explain?cmd=nc+127.0.0.1+-p+80

[+] idank|9 years ago|reply
It boils down to a bunch of heuristics so there are gaps if the man page is slightly off of what it expects.
[+] frankhorrigan|9 years ago|reply
I'm not saying that this _is_ a phishing scam. But if it is, hoo boy it's a clever one.
[+] kevincox|9 years ago|reply
Cool tool. I think what would really be the icing on the cake is if it substitued the actual command into the documentation. Removing that one layer of indirection would make it that much easier to understand.

For example:

foo() { bar }

> This defines a function named "foo".

Also that example fails to parse. Even though :() { :|: };: works so it seems like there is a certian amount of special casing.

[+] idank|9 years ago|reply
That's an awesome idea. I'd love to try that one day.

Your command isn't valid because it's missing a control character after 'bar', such as ';'. Bash rejects it as well:

  $ bash -c "foo() { bar }"
  bash: -c: line 1: syntax error: unexpected end of file
[+] cheeze|9 years ago|reply
Pretty awesome, but broke on the first command I tried (granted, it is bash specific IIRC)

echo $(( 1 + 2 ))

[+] cat199|9 years ago|reply
not at all a bashism

  $ uname -sr
  OpenBSD 6.0
  $ ps T
    PID TT  STAT       TIME COMMAND
  85828 pc  Ssp     0:00.01 -ksh (ksh)
  34802 pc  R+p     0:00.00 ps -T
  $ echo $(( 1 + 2 ))    
  3
[+] danellis|9 years ago|reply
If you hover over something that points to a description that's not currently in view, you can't scroll to the description without unhovering and hence unhighlighting the line pointing to the right description.
[+] idank|9 years ago|reply
How do you mean? Seems to work for me. Please file a bug report with how to reproduce!
[+] JasonSage|9 years ago|reply
There are several commands on OS X that behave a bit differently from their traditional UNIX counterparts. grep is the big one that springs to mind—any given grep shell-fu may just not work on OS X and I'll find myself having to reconstruct the arguments from scratch to get it working.

I'd love to see a fork of explainshell or an option in the interface to deal with items like this which are specific to OS X. Let me put a grep command in for OS X and have it show me what options I'm using which are undocumented—that would be nifty.

[+] umanwizard|9 years ago|reply
By "traditional UNIX" do you mean GNU specifically? What on macOS differs more from standards than does the typical Linux distro?
[+] stirner|9 years ago|reply
The BSD coreutils that macOS uses are much more "traditional UNIX" than the GNU coreutils.
[+] abraves10001|9 years ago|reply
As a relatively new programmer and one who went to one of those mediocre bootcamps, resources like this are invaluable. Thanks!