Re: [dev] sbase installed first impressions

From: Evan Gates <evan.gates_AT_gmail.com>
Date: Mon, 3 Oct 2016 16:43:25 -0700

On Mon, Oct 3, 2016 at 4:34 PM, stephen Turner
<stephen.n.turner_AT_gmail.com> wrote:
> _AT_Evan
> I am not too fluent at advanced shell at the moment so help me out
> with this one please, I checked the advanced scripting guide but want
> to make sure i understand this.

Please do not read that, it's full of practices that are outdated and
in many cases it is plane wrong. Instead check out the bash guide[0]
and the accompanying bash faq[1] and bash pitfalls[2]. Although the
wiki is bash specific it also covers POSIX sh very well.

> s() { ls -F "$_AT_" | cols; }
> s() implies that you have created an alias for ls as "s" and the () is
> to listen for what follows for the flags "-h etc"?

It's a function definition.

> {} is to encapsulate the real commands,

The body of a function is a compound command, meaning it's one of:
a list in braces
a list in parens
a loop (for, while until)
an if statement (with following elif, else)
a case statement

That said most often you'll see braces.

> ls -F "$_AT_" the "$@" is to pass along the flags from s()?

"$_AT_" expands to the positional parameters (arguments) and must be
quoted otherwise you can run into further word splitting and glob
expansion (this is true for all expansions/substitutions).

> and for the ; at the end of cols, i assume this terminates in a way
> that prevents it from grabbing further input?

A terminator is needed before the closing brace, both newline and
semicolon are accepted.

[0] http://mywiki.wooledge.org/BashGuide
[1] http://mywiki.wooledge.org/BashFAQ
[2] http://mywiki.wooledge.org/BashPitfalls
Received on Tue Oct 04 2016 - 01:43:25 CEST

This archive was generated by hypermail 2.3.0 : Tue Oct 04 2016 - 01:48:11 CEST