Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 May 2013 23:41:36 +0000
From:      "Teske, Devin" <Devin.Teske@fisglobal.com>
To:        Polytropon <freebsd@edvax.de>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>, "Teske, Devin" <Devin.Teske@fisglobal.com>
Subject:   Re: check variable content size in sh script
Message-ID:  <13CA24D6AB415D428143D44749F57D7201F507DD@ltcfiswmsgmb26>
In-Reply-To: <20130518180634.9e5fd3c2.freebsd@edvax.de>
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>

next in thread | previous in thread | raw e-mail | index | archive | help

On May 18, 2013, at 9:06 AM, Polytropon wrote:

> On Sat, 18 May 2013 11:58:30 -0400, Quartz wrote:
>>=20
>>>> newfoo=3D${foo:0:51}
>>>>=20
>>>=20
>>> That works for bash, not sh.
>>=20
>> Ok granted, but I don't think that ${#foo} is straight sh either, so I=20
>> assumed "things bash/tcsh/ksh/whatever accept when running in sh=20
>> emulation" were ok.
>=20
> By default, there is no bash on FreeBSD, and therefor no emulation
> and "implicit features". :-)
>=20
> At least FreeBSD's implementation of sh (which is ash, I think)

dash actually -- the Debian Almquist shell (descendent of NetBSD's ash).
--=20
Devin



> supports the # functionality. From "man sh":
>=20
>     ${#parameter}
>             String Length.  The length in characters of the value of
>             parameter.
>=20
> And:
>=20
>     ${parameter#word}
>             Remove Smallest Prefix Pattern.  The word is expanded to prod=
uce
>             a pattern.  The parameter expansion then results in parameter,
>             with the smallest portion of the prefix matched by the pattern
>             deleted.
>=20
> Check the chapter "Parameter Expansion" for more surprising
> things that are supported by ye olde /bin/sh. :-)
>=20
>=20
>=20
> --=20
> Polytropon
> Magdeburg, Germany
> Happy FreeBSD user since 4.0
> Andra moi ennepe, Mousa, ...
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.o=
rg"

_____________
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?13CA24D6AB415D428143D44749F57D7201F507DD>