News for hackers. Stuff that matters.
Re:Bash-Fu by billybob on Thursday March 24, 2011 @06:58AM (#2363549)
You know, I work at the command line all day, and I'm always happy to learn a new trick. But for writing actual scripts, I'd much rather write in Ruby. I don't want to have to use awkward syntax like case statements ending with "esac."

Yes, using Ruby introduces a dependency beyond Unix. But I already use lots of libraries (Rails, Rspec, etc) and tools (ImageMagick, Ghostscript), so I don't see that as a problem, just part of the job.

Re:Bash-Fu by wladimir on Thursday March 24, 2011 @07:49AM (#2363633)
Indeed, I've long ago adopted the convention to do any remotely advanced scripting in a "real" scripting/programming language (myself, I use Python for this).

Bash scripting is good for running a few commands in a sequence, but in my experience gets unmaintainable and unreadable very quickly, especially if you try to do sane error handling/logging, or operations on non-text data.

Re:Bash-Fu by billybob on Thursday March 24, 2011 @07:54AM (#2363643)
Agreed. Although I should add that it's still great to call out to the standard Unix toolset when it's the easiest way to get something done. The accepted answer here illustrates that: http://stackoverflow.com/questions/4714043/what-is-the-best-...
Re:Bash-Fu by JonnieCache on Thursday March 24, 2011 @08:12AM (#2363675)
A quick...

    require 'fileutils'
    include FileUtils
...and you can almost pretend you are writing bash.

http://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/index.html

Re:Bash-Fu by krainboltgreene on Thursday March 24, 2011 @11:05AM (#2364360)
FileUtils is a step back as far as I'm concerned. In fact, all the file-stuff is both ill-documented and anti-ruby-readability.
Re:Bash-Fu by obiterdictum on Thursday March 24, 2011 @01:34AM (#2362995)
What does this minimalistic page offer except links to (already) rather well-known Bash resources? Am I missing something?
Re:Bash-Fu by obiterdictum on Thursday March 24, 2011 @05:32AM (#2363396)
PS

I can't edit my post anymore, but I remembered that there is a similarly named site for command line tricks:

http://www.commandlinefu.com

Re:Bash-Fu by piramida on Thursday March 24, 2011 @02:32AM (#2363107)
The bash-fu is weak within that site.
Re:Bash-Fu by BrandonM on Thursday March 24, 2011 @09:08AM (#2363888)
I'll use command lines like that when I just need to get something done (after verifying that there are no files named "foo.sym"), but to write a script that uses a hard-coded filename that could stomp on other files is pretty bad. If you have a symlink foo and a file foo.sym, you've just erased foo.sym. The script also leaves all the .sym symlinks behind; it's not clear that this is the desired behavior.

If you're going to make a site and call it bash-fu, shouldn't you make sure your bash is at least good?

Re:Bash-Fu by saurik on Thursday March 24, 2011 @10:41AM (#2364271)
I was also really bothered that the script failed to handle filenames that may contain spaces correctly.
Re:Bash-Fu by BrandonM on Thursday March 24, 2011 @05:45PM (#2366155)
Good catch.
Re:Bash-Fu by limmeau on Thursday March 24, 2011 @06:21AM (#2363487)
Exercise: make repl_links.sh work also when filenames contain blanks.
Re:Bash-Fu by fjarlq on Thursday March 24, 2011 @01:34AM (#2362997)
What's up with the difficult colors? I'm using Chrome 10 beta on OS X 10.6.

http://i.imgur.com/ya8WI.png

Re:Bash-Fu by magicofpi on Thursday March 24, 2011 @01:45AM (#2363023)
That's strange. It looks fine on FF4 using Snow Leopard.

http://d.pr/LXvR

Re:Bash-Fu by tygorius on Thursday March 24, 2011 @02:03AM (#2363058)
I think it was a reference to the color scheme in the screen shot, not to the site itself. I find choices like dark blue and brown against black to be hard to read.
Re:Bash-Fu by wtallis on Thursday March 24, 2011 @02:52AM (#2363154)
You've probably got a low-quality LCD with a bad color calibration, then, or else just a really bad contrast ratio or lots of glare. That color scheme doesn't seem to me to have any colors that would clash, even to colorblind and partially-colorblind people. Sure, it's a relatively low-contrast color scheme, but I think it would be generally harder to read if the contrast were really high. You shouldn't use much in the way of full-intensity colors when you have a black background.
Re:Bash-Fu by billswift on Thursday March 24, 2011 @06:07AM (#2363454)
It looks like it is a modified version of normal emacs highlighting for shell scripts to me; the colors are different from the defaults on my computer but not wildly so.
Re:Bash-Fu by pavel_lishin on Thursday March 24, 2011 @10:19AM (#2364144)
It's merely an accurate representation of the difficulty involved in writing bash scripts, as compared to just about everything else.
Re:Bash-Fu by lamby on Thursday March 24, 2011 @05:15AM (#2363365)
More like POSIX shell fu - the example doesn't actually use any Bash-specific features.
Re:Bash-Fu by kree10 on Thursday March 24, 2011 @10:17AM (#2364138)
Seeing #!/bin/bash is one of my pet peeves.

If it's a straight shell script, use "#!/bin/sh" please. If the script actually requires bash features, I'd appreciate "#!/usr/bin/env bash" because if I choose to install bash, it probably won't be in /bin.