Date: Sun, 12 Oct 2014 16:09:39 +0200 From: Polytropon <freebsd@edvax.de> To: CyberLeo Kitsana <cyberleo@cyberleo.net> Cc: "William A. Mahaffey III" <wam@hiwaay.net>, FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: sh man page .... Message-ID: <20141012160939.f131b6b9.freebsd@edvax.de> In-Reply-To: <5439C1D0.6030902@cyberleo.net> References: <5437FB8B.9080008@hiwaay.net> <5439C1D0.6030902@cyberleo.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 11 Oct 2014 18:48:32 -0500, CyberLeo Kitsana wrote: > Try running devel/checkbashisms against the scripts. It's something > Debian uses to ease migration from Bash to Dash in their base system, > and I've found it rather useful to ensure no bashisms sneak into my own > portable scripts. This is a very good advice, because "portable scripts" isn't entirely obvious and normal in Linux anymore. And as soon as you leave the Linux world and need to have the same script run on other UNIX systems (BSD, Solaris, maybe even HP-UX or AIX, maybe even on Mac OS X, or if you're totally insane, on IRIX), having the scripts rely on things you take for granted ("because it works in bash, and that's the same thing across all platforms, right?") is a bad idea. For example, you can easily spot Linux scripts if their first line is "#!/bin/bash". This isn't even "standard" anymore on Linux, as some distributions have moved to the dash shell as their default scripting shell. But just writing "#!/bin/sh" doesn't make bashisms magically work on non-bash shells. Having a tool to test for those cases is a good help, so you don't run into "unexpected behaviour" in combination with the "works on _my_ machine" mentality. Oh, and don't get me started on the rare fact that you think you have a POSIX shell, and your script only uses what POSIX specifies, and then you suddenly find out that the shell isn't 100% POSIX... :-) -- 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?20141012160939.f131b6b9.freebsd>