Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Oct 2020 14:37:55 -0600
From:      Bob Proulx <bob@proulx.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: sh scripting question
Message-ID:  <20201018141345096243637@bob.proulx.com>
In-Reply-To: <c6096f5d-84f5-af81-7407-9bda06c7b240@panix.com>
References:  <24456.60388.135834.43951@jerusalem.litteratus.org> <20201015204226099763897@bob.proulx.com> <c6096f5d-84f5-af81-7407-9bda06c7b240@panix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Kurt Hackenberg wrote:
> Bob Proulx wrote:
> 
> > Oh you are tormenting us now.  :-)  There are some subtle issues here.
> 
> Maybe a shell is the wrong tool.

And yet just the same the shell does handle whitespace and arbitrary
characters in file names easily.

    while IFS= read -r line; do
      printf "|%s|\n" "$line"
    done < file1

It's a shell programming idiom.  It accomplishes the task very easily.
For people programming in the shell every day this type of construct
rolls off the fingers like a native language.  But it may not be
immediately obvious without a hint that this is what is needed.

    Idiom, id-ee-uhm, noun. An expression conforming or appropriate to
    the peculiar structural form of a language.

Nothing we have seen yet makes the shell the wrong tool.  The shell is
a very powerful command and control language.  And so far the original
need was still for using it specifically as a command and control
language.  So all good so far!  If we move to needing complex data
structures however that is where my decision point is set to move to a
language that supports complex data types.

And I think everyone is in agreement that the filenames that were
chosen were not the file names that any Unix person would choose to
name their files.  No disagreement there.  I am sure they were chosen
by less enlightened individuals.  Given that the files on disk were
chosen for a different purpose then can we handle them easily in the
shell?  Yes.  So far nothing too difficult! :-)

Bob



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201018141345096243637>