From owner-freebsd-questions@FreeBSD.ORG Sat May 18 23:41:41 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3563368D for ; Sat, 18 May 2013 23:41:41 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id 03CFC9AB for ; Sat, 18 May 2013 23:41:40 +0000 (UTC) Received: from smtp.fisglobal.com ([10.132.206.15]) by ltcfislmsgpa05.fnfis.com (8.14.5/8.14.5) with ESMTP id r4INfbb5032274 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Sat, 18 May 2013 18:41:37 -0500 Received: from LTCFISWMSGMB26.FNFIS.com ([10.132.99.18]) by LTCFISWMSGHT04.FNFIS.com ([10.132.206.15]) with mapi id 14.02.0309.002; Sat, 18 May 2013 18:41:36 -0500 From: "Teske, Devin" To: Polytropon Subject: Re: check variable content size in sh script Thread-Topic: check variable content size in sh script Thread-Index: AQHOUkc8OBFwBehJxk+zMS+kIvSMRZkIQzQAgAAKzgCAAxSDAIAAAS6AgAAMpACAAAJBAIAAfyMA Date: Sat, 18 May 2013 23:41:36 +0000 Message-ID: <13CA24D6AB415D428143D44749F57D7201F507DD@ltcfiswmsgmb26> 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> In-Reply-To: <20130518180634.9e5fd3c2.freebsd@edvax.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.132.253.126] Content-Type: text/plain; charset="us-ascii" Content-ID: <7E1DE0B5244A2B488B539DBCF223E229@fisglobal.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8626, 1.0.431, 0.0.0000 definitions=2013-05-18_08:2013-05-17,2013-05-18,1970-01-01 signatures=0 Cc: FreeBSD Questions , "Teske, Devin" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Devin Teske List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 May 2013 23:41:41 -0000 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.