Date: Wed, 1 Feb 2017 17:23:13 +0100 From: Polytropon <freebsd@edvax.de> To: Roger Pate <roger@qxxy.com> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: Variable assignment in sh Message-ID: <20170201172313.3a3eee93.freebsd@edvax.de> In-Reply-To: <CADTH-osmMTbJbC2jsY=LzEEO-K7SDfMusDqnLe2V4%2B-3P2SEmg@mail.gmail.com> References: <b831bd9e40321e59910ea8913c7a6302.squirrel@webmail.harte-lyne.ca> <20170131161824.a9f1ef46.freebsd@edvax.de> <b553c644fccc211f9658b31cfe65e8a0.squirrel@webmail.harte-lyne.ca> <20170131185103.7f911dfb.freebsd@edvax.de> <5f51e2c3bdb8a20c6a7786c2b345c957.squirrel@webmail.harte-lyne.ca> <alpine.BSF.2.20.1701311445520.54303@wonkity.com> <20170201014858.eec196d0.freebsd@edvax.de> <VI1PR02MB09748570B8832CAA397D19FFF64D0@VI1PR02MB0974.eurprd02.prod.outlook.com> <CADTH-osmMTbJbC2jsY=LzEEO-K7SDfMusDqnLe2V4%2B-3P2SEmg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 1 Feb 2017 10:06:33 -0500, Roger Pate wrote: > On Tue, Jan 31, 2017 at 8:26 PM, Manish Jain > <bourne.identity@hotmail.com> wrote: > > A point here for bash scripting. > > Most often, but not always, if I need something bash has and /bin/sh > lacks, it's time to write that script in a different language. :P Don't confuse sh with bash, they're not fully interchangeable. While sh ("classic Bourne shell") is quite portable and usually POSIX, bash is not. Even on Linux, sometimes bash != bash, and sometimes it's dash. You can see bash as a superset of sh, so you can do testing of sh scripts with bash quite well, even in the "line by line" interactive manner. If you need stuff to work across different operating systems, sh is often called "lowest common denominator" as most UNIX systems default to it as scripting shell. If you need "bash-isms" (features that bash has, but sh doesn't), there are also some portable ways to deal with the shebang line, but don't assume that bash is installed everywhere as /bin/bash. :-) Of course you are right: When you reach the border of what a shell language can do, consider using better tools, more suitable for the task you want to solve. For example, if you find yourself in a while read something | cut | cut | sed | grep | sed | sort piping chain, consider using awk. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170201172313.3a3eee93.freebsd>