Minimal skills

Steve O'Hara-Smith steve at sohara.org
Thu Jun 4 09:16:33 UTC 2020


On Thu, 4 Jun 2020 10:55:03 +0200
Ralf Mardorf via freebsd-questions <freebsd-questions at freebsd.org> wrote:

> On Thu, 4 Jun 2020 02:25:30 -0600, Brandon helsley wrote:
> >First, before I try to understand that. What exactly is "writing shell
> >scripts" is this similar to editing resource script files like
> >.xinitrc or .xsession?
> 
> Those _are_ shell scripts.

	However they are typically very minimal shell scripts that just
launch a handful of programs and maybe set a variable or two.

	The various unix user shells embed quite powerful programming
languages, much of the system is based around small programs written in the
language supported by /bin/sh - these are also called shell scripts.

	All the documentation on that language is in the sh manpage (man
sh) as highly condensed reference documentation. There are many tutorials
on shell programming - the only thing to watch out for are Linux centred
ones that assume bash with all its extensions to the sh language.

	It is possible to write surprisingly sophisticated programs in
shell, it is not particularly wise to do so, the language is best suited to
short programs - often embedding pipelines to save typing (or forgetting
options) like this one I used to render troff files in book format:

#!/bin/sh

BOOK=$1
groff "$BOOK" | psbook -s4 | psnup -2 -m27 | lpr -C duplex:shortbind

	Usually scripts like this start life on the command line and get
put into a script file for safe keeping. I have a *lot* of them mostly
obsolete :)

-- 
Steve O'Hara-Smith <steve at sohara.org>


More information about the freebsd-questions mailing list