I thought only unix and unix-like shells would be covered. I wonder what the technical definition of a shell is though.
(genuinely curious, not trying to be snarky)
Yes, given the definiton of shell being a user interface to an operating system, typically command line, powershell is considered a shell and can function as one. For example, while many think of windows servers as being all gui, newer versions of windows (server) can be run entirely in cli mode with no gui via powershell, in which supposedly any management technique normally done through gui can be done through the ps cli.
The main difference between nix shells and powershell is that the nix shells are text based, while powershell is object based due to it's .NET core.
As a sysadmin who uses both bash and powershell, I have to say the more recent versions of powershell are quite powerful and a fresh breath of air to use in the normally stale windows world. Of course, I tend to use pywinrm to remotely run ps commands so I don't too dirty touching the tainted MS ecosystem. (That's my way of saying that while powershell is nice and a large improvement over batch command line files, bash is still the better one due to the underlying unix philosophy and the GNU ecosystem)
The original description was listed as "explain any shell command". That was an erroneous title that's since been updated.
echo $(( 1 + 2 ))
$ 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 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.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!
Still, the website might be running on a modified version.
Having said that, please don't send sensitive information to a random service on the internet. :)
Who came up with this security model anyway?
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.
Linux: `date -d '10 mins ago'` Mac: `date -v -10M`
There's loads of tiny differences like this. Often just old versions, and you can pull in the latest with `brew` or something.
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
}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.
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 filehttp://explainshell.com/explain?cmd=dd+if%3D%2Fdev%2Furandom...
e.g. explain cat foo.txt > out.txt
Though if you wanted it to actually explain `cat foo.txt > out.txt` and not just output the explanation for `cat foo.txt` to `out.txt` you'd probably have to put that in quotes.
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?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?
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
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.
Looks like it doesn't deal with subshells, but otherwise it did reasonably well.
http://explainshell.com/explain?cmd=find+.+-name+*.pb.cc+%7C...
file=$(echo `basename "$file"`)
This is a horrible example, since it has a "useless use of echo", forcing nested evaluations and a bashism. Basename prints to stdout too!The sh-compatible, simpler equivalent:
file=`basename "$file"`If it only had a CLI so that I could use it directly from my terminal...