Date: Sun, 19 May 2013 00:06:47 +0000 From: "Teske, Devin" <Devin.Teske@fisglobal.com> To: Quartz <quartz@sneakertech.com> Cc: "<freebsd-questions@freebsd.org>" <freebsd-questions@freebsd.org> Subject: Re: check variable content size in sh script Message-ID: <13CA24D6AB415D428143D44749F57D7201F508F2@ltcfiswmsgmb26> In-Reply-To: <519814A7.8070702@sneakertech.com> References: <5194F65F.6080503@a1poweruser.com> <5194FB0A.9090400@tundraware.com> <13CA24D6AB415D428143D44749F57D7201F4D41F@ltcfiswmsgmb26> <5197998E.6050200@sneakertech.com> <51979A8B.8080703@tundraware.com> <5197A526.7020302@sneakertech.com> <20130518180634.9e5fd3c2.freebsd@edvax.de> <519814A7.8070702@sneakertech.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On May 18, 2013, at 4:54 PM, Quartz wrote: >=20 >> #foo works with sh >=20 > Is it actually part of the official spec though is what I'm wondering, or= is it a case of other shells not rejecting 'advanced' statements when runn= ing in emulation. >=20 Shells don't have an "emulation mode". The shell supports what it supports,= and no shell that I've ever used had an "emulation mode" to act like anoth= er shell. Maybe you're referring to as "emulation" is actually the invocation line of= the shell script. Make no mistake=85 when you change the invocation (first) line of a shell s= cript from: #/bin/sh to: #/bin/tcsh You are not instructing a shell to "emulate" anything, you are actually usi= ng a different shell. sh !=3D tcsh !=3D bash !=3D ash !=3D dash !=3D zsh Your script will use the shell that is written in the innovation line and t= he features you get are respective to which shell you choose. >=20 >> At least FreeBSD's implementation of sh (which is ash, I think) >> supports the # functionality. >=20 > The reason I say all this is that my copy of tcsh (on this not-freebsd ma= chine) *doesn't* work with this when in sh emulation. >=20 Get the idea that "csh" or "tcsh" are *anything* like sh out of your mind. Further, you almost *never* want to do any serious shell programming in csh= or tcsh. Why? Because csh and tcsh have an incomplete programming spec. Most notably= are the way that it handles pipe data and the standard-output/error file d= escriptors. Specifically, you cannot throw away stdout while keeping stderr= . This short-coming may not be noticeable to all programmers that choose cs= h/tcsh, but if you want to do any serious programming, you'll eventually hi= t those limitations and be forced to move to a real shell (real in the sens= e that it has a complete programming specification). I personally never recommend csh/tcsh as a scripting language=85 but I can = see the benefit that certain constructs (like "repeat N cmd") have, purely = for their simplicity (and readability for *very* short scripts). To challen= ge myself on this topic, I routinely try and cross-port very complex shell = scripts to csh, and while I can do math with "let" and I can other things t= hat a *normal* scripting language should allow=85 I invariably end up runni= ng away screaming in frustration. Again, csh !=3D tcsh !=3D sh !=3D bash !=3D ash !=3D dash !=3D zsh --=20 Devin _____________ The information contained in this message is proprietary and/or confidentia= l. If you are not the intended recipient, please: (i) delete the message an= d all copies; (ii) do not disclose, distribute or use the message in any ma= nner; and (iii) notify the sender immediately. In addition, please be aware= that any message addressed to our domain is subject to archiving and revie= w by persons other than the intended recipient. Thank you.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?13CA24D6AB415D428143D44749F57D7201F508F2>