Earlier quoted context omitted.
And it's all 2 minutes to add it as your default shell (including installing brew itself). 22:06 ~ $ bash --version GNU bash, version 4.4.12(1)-release (x86_64-apple- darwin16.3.0) Much easier than constraining oneself about what to put in one's script (assuming one is indeed targeting Linux, OS X etc released in the last 10+ years and not some embedded etc platforms).
If your project says it requires something from brew thats a blocker for a number of people.
Things I Wish I'd Known About Bash
221–230 of 272 posts
Re: Things I Wish I'd Known About Bash
#222Hang out in #bash on IRC Freenode and you will be a Bash jedi http://mywiki.wooledge.org/BashFAQ best resource IMO for quick Bash syntax lookups as I always need to refer to the BashFaq to remember parameter expansion sub-string retrieval. parameter result ----------- ------------------------------ $name polish.ostrich.racing.champion ${name#*.} ostrich.racing.champion ${name##*.} champion ${name%%.*} polish ${name%.…
They are needlessly rude and mean at #bash. A bunch of scumbags, actually.
Re: Things I Wish I'd Known About Bash
#223Earlier quoted context omitted.
If your project says it requires something from brew thats a blocker for a number of people.
A mythical kind of project that depends on macOS having a recent bash?
A posix conptible shell script has no such limitation. Thats all im saying. Im not arguing the merits of which bash is better or what a project might need.
Re: Things I Wish I'd Known About Bash
#224Earlier quoted context omitted.
As someone who also has to semi-frequently modify 100+ lines bash scripts written by others, I'd suggest every serious bash scripter read the bash man page. It is much smaller than any book on Python. For scripts written in Python, I'd use a similar argument and suggest every serious Python scripter to learn Python. As for Perl, or Ruby, or Julia, or anything really. It's just that learning bash from its man page is,…
The problem is most people don't want to consider themselves "serious bash scripters" but still think they can write bash, which always results in unstable and vulnerable scripts. Python on the other hand can be written by unserious python scripters and more often be at least accidentally correct. Another big issue is that the quoting, escaping and expansion rules in bash can be daunting even for serious bash scripte…
But they know how to accomplish this task interactively in the shell, so scripting what they're already doing (or already know how to do) seems like the natural next step. So you wind up with an imperative shell script that's basically a long, flat sequence of commands with some logic and variables sprinkled in haphazardly as they realized they needed it.
Due to the organic way these scripts often emerge, it's not like advocating Python is an easy sell. By the time they think to consider alternatives, the shell version already exists.
Re: Things I Wish I'd Known About Bash
#225Earlier quoted context omitted.
Well put it this way: You can assume everyone has a modern bash, and make it the end users problem if they don't, or you can write portable shell scripts and know it will work. Honestly the things you can't do in posix shell compared to bash border on "use a fully featured language" anyway.
Thing is that Bash is something you can assume to be reasonably widely available[0] — like Perl or Python — but I wouldn't expect to have to avoid any features from the last 10 years of either of those two. Sure, a certain grace period is to be expected but I think 10 years is way past that. [0]: I know POSIX is supposed to be even more widely available but depending on what you're targeting then it may not be the be…
Thats the blocker on macOS.
Re: Things I Wish I'd Known About Bash
#226Earlier quoted context omitted.
Which is why the parent advised to treat the man page like a reference document, by searching in it. Some man pages are just badly written and are indigestible even when searching for a specific thing, but in general, that approach works quite often.
Is there some trick to searching man pages that I don’t know? Because my usual experience is: type man foo type /-p type n n n n n n n n n as there are a bunch of matches like “...does bar when combined with -p...” A presentation of man pages that used hypertext would make me a lot happier.
If you’re using mandoc (http://mandoc.bsd.lv/) as your man(1) program—the default on OpenBSD and a couple of Linuxes like Void and Alpine—it will use these semantics to generate hyperlinks in the terminal using more(1) and less(1)’s ctags support.
So on my machine, your example becomes:
type man foo
type :t
type p
This brings me to the first instance of a command‐line flag named “-p” or environment variable named “p” in an itemized list.It translates to HTML too—check out the links generated by the web viewer, which uses the same backend. https://man.openbsd.org/ls.1
Re: Things I Wish I'd Known About Bash
#227Earlier quoted context omitted.
Thanks, but I think this validates a demand for real hypertext.
While you’re waiting for the rest of the world to agree with you and then implement the true hypertext manuals, consider sharpening your regex saw.
Re: Things I Wish I'd Known About Bash
#228Earlier quoted context omitted.
I don't think that's correct, do you have an example? This works for me: $ var=$(echo $'a\nb') $ echo "$var" a b
Oh, I meant before the trailing newlines, sorry for being unclear. Try using a\nb\n\n\n instead of a\nb and observing that the output doesn't change.
Re: Things I Wish I'd Known About Bash
#229Earlier quoted context omitted.
man man man less Not a joke. Learn the simple tools that help you daily.
Did you have something in mind? I’ve read those man pages before, and I read them again today, and with the possible exception of tags in less (but I’m not sure about that), nothing seems relevant.
What helps me somehow is the fact that definitions in man pages are usually start on a new line and are indented by several spaces.
man bash
/ -o
This finds an inline mention, not very useful. man bash
/^ +-o
This finds the definition: start of line, then some space, then the -o.Re: Things I Wish I'd Known About Bash
#230Earlier quoted context omitted.
Fewer key presses, but doesn't work if you're using vi bindings.
ESC _ or M-_ does work in vi mode though (and does the same thing as ESC ./M-.). Search for "yank-last-arg" in the bash manual.
Went searching how to do it in Zsh as well when the Zshell Line Editor (zle) is configured in vi mode:
$ bindkey -M viins '\e.' insert-last-word
Will make ESC-. work from insert mode.