Re:hr for your terminal
by sp332 on Monday February 10, 2014 @03:21PM
(#7213509)
What language is that?
[ Parent
| on HN ]
bash shell, although some whitespace is missing:
hr() { printf '=%.0s' $(seq $COLUMNS); }
printf is a bash builtinActually printf is a POSIX standard shell utility. Bash happens to implement it as a builtin, but there's also a conforming copy in GNU coreutils (and presumably busybox, but I didn't check). And the syntax above is standard Bourne shell, not specifically bash.
Actually of the constructs in that, the only non-portable one is the seq tool, which (I think) is unique to coreutils.
I don't know if its still the case, but OSX used to not ship with seq. Instead, you had to use jot.
OSX 10.9 ships a 'seq'. This particular version was written in 2005 by the NetBSD project, and its provenance is NetBSD 3.0 -> FreeBSD 9.0 -> OSX.
Fwiw, it isn't a GNUism, though GNU's version was the first widely distributed one. A 'seq' appears in some old Research UNIX editions, and also in Plan9, but not in commercial AT&T Unix or in BSD. Instead 'jot' is the traditional BSD utility. Not sure if commercial AT&T Unix (and descendants) had anything similar.
zsh
yup, using zsh, I tend to forgot that Bash needs spaces inside brackets. This is a good reminder though:
:(){ :|:& };:
Edit: don't run this, it's a forkbomb