9 ms·
Bash [ -z hello ]
- JoshTriplett 12y agoNice! It's too bad that this doesn't actually evaluate the expression in a sandbox, but nonetheless it's a very handy syntax guide. It'd be nice to see option descriptions extracted from manpages: searching for "df -h" could then produce: -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
- jmakeig 12y agohttp://explainshell.com http://explainshell.com is what you're looking for.
- JoshTriplett 12y agoI'm aware of it; I'd love to see that functionality integrated into DDG.
- idank 12y agoActually one of their guys approached me last time explainshell appeared on HN. I think he suggested I implement it as some sort of shortcut, but I haven't had time to look into it. I have a branch somewhere that exposes the results as JSON, which should make it easy to integrate if they were interested.
- Alupis 12y agoWhat a great resource! I did not know about this before today!
- voltagex_ 12y agoI wonder if the developer of explainshell is reading. It looks like development has stalled. It's a really nice idea and could serve as a powerful backend for DDG.
- idank 12y agoI am reading this! Admittedly I haven't had a lot of time recently to improve explainshell. But I haven't deserted it; it's just a matter of finding a block of free days to focus on it. (and as always, patches are welcome ;)
- deleted 12y ago[deleted]
- idank 12y agoThere is one in its own file: https://github.com/idank/explainshell/blob/master/TODO https://github.com/idank/explainshell/blob/master/TODO It's slightly out of sync with the github issues though.
- voltagex_ 12y agoDeleted my comment 10 seconds after you posted yours, I must be blind :P Looked straight past it.
- frabcus 12y agoI note that queries like https://duckduckgo.com/?q=man+df https://duckduckgo.com/?q=man+df put in a box from LinuxCommand.org
- Nyubis 12y agoThis is pretty awesome, but I don't know if people often phrase their queries like that, and I'm not sure whether it's worth it to start phrasing it like this. It doesn't seem to support more complex bash queries, so I'm not really sure how often this will be used.
- mattdanger 12y ago[ is part of Bash syntax
- frou_dh 12y ago...and perhaps surprisingly also a program sitting on disk. $ type [ [ is a shell builtin $ [ 1 -gt 0 bash: [: missing `]' $ whereis [ /bin/[ $ /bin/[ 1 -gt 0 # success
- mappu 12y agoYou got a root shell out of `/bin/[` ? Impressive :)
- e12e 12y agoHm, which version of [ is that? I get: $ /usr/bin/[ 1 -gt 0 && echo success /usr/bin/[: missing `]' $ /usr/bin/[ 1 -gt 0 ] && echo success success (This is from coreutils 8.13-3.5 on Debian GNU/Linux)
- frou_dh 12y agoWhat ships in OS X 10.9, presumably BSD-derived.
- embolalia 12y agoNooo! Mistake #0 about shell scripting is thinking [ is syntax. It makes it way more weird and inexplicable. [ is a command, just like any other. That's why there needs to be a space between it and the next thing, and why you have to use weird looking flags and such. This is why I prefer the command `test`. It does the same thing as `[`, but is more obviously a command. And when you see it as a command, it's obvious that any command can be used in an if directly; if is just checking the exit code. (Whenever I see someone doing `if [ $? -ne 0 ]`, it makes me cry.)
- the_french 12y agoIt seems like DDG is positioning itself to become WolframAlpha for tech. Hopefully, this will allow it to better catch the exact market segment that would be wary of search engine tracking (educated tech-savvy people).
- pornel 12y agoMore please! e.g. bash $? is not explained.
- jagtalon 12y agoIf you're interested, you can add that in to https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/BashPrimaryExpressions.pm https://github.com/duckduckgo/zeroclickinfo-goodies/blob/mas... since it's open source.
- Crisco 12y agoI've been reading through some of those goodies, and they all seem pretty cool, but I'm wondering how secure using the 4 word random passphrase generator[0] would be... [0] https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Passphrase.pm https://github.com/duckduckgo/zeroclickinfo-goodies/blob/mas...
- mikeash 12y agoNot at all secure if you run it on DDG, since you give your password to a third party before you even get it yourself.
- rsl7 12y agoBut of course you could run it ten times and pick one of them. Or modify the instant answer to return ten or twenty. Not ideal or optimal, but there it is.
- mikeash 12y agoThat hardly helps at all. Now instead of knowing your exact password, your attacker knows that your password is one of these 10-20 entries, and it's easy to just try them all.
- 12y ago
- imacomputer2 12y ago"results to true if the length of 'hello' is zero." I'm glad they cleared that up. Otherwise, I might have assumed that there was no case where 'hello' had a length of zero. Joking aside, it is a useful syntax guide.
- chx 12y agoAnd yet, the top search result is tldp. This is what #bash on freenode has to say about that site: > The infamous "Advanced" Bash Scripting Guide should be avoided unless you know how to filter out the junk. It will teach you to write bugs, not scripts. In that light, the BashGuide was written: http://mywiki.wooledge.org/BashGuide http://mywiki.wooledge.org/BashGuide Now, that site is on the second "page" of the search results.
- zhemao 12y agoTo be fair, searching it in Google also gives TLDP pages as the top results. I think TLDP just has better SEO.
- n0rm 12y agoIt just has more nodes pointing to its links. That's the danger behind PageRank. If something false is popular enough, it will replace fact.
- pavs 12y agoNot just more nodes, then it would have been easy, but more "credible and relevant" nodes. At least that's the idea.
- Alupis 12y agocorrect. simple back-links no longer have the weight they used to (and in some situations can actually harm your SEO). Backlinks must come from other reputable (in google's algorithm's eye's) sites before they carry any weight. So, this would mean, tldp.org has a lot of top-ranked linux/bash and related sites pointing to it's pages.
- PhasmaFelis 12y agoIs there any alternative, though? You can't algorithmically determine truth.
- est 12y agoDamn, should draw FSA fors RegExps. Like this https://www.debuggex.com/r/IC3q9sEdkKjhuLWU https://www.debuggex.com/r/IC3q9sEdkKjhuLWU And explains it like this http://regex101.com/ http://regex101.com/
- wicket 12y agoThere should a dollar sign before hello, e.g.: bash [ -z $hello ] ...or is that a bashism that I'm not aware of? If so, that's just horrible. Personally, I prefer to write portable shell scripts. Entering "!posix test" into DuckDuckGo to obtain the man page for "test" yields far more meaningful information for the same problem.
- d0m 12y agoAs an aside, I think the new design is perfect. Good job on iterating on the feedback!