From nobody Tue Nov 07 08:21:03 2023 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SPh4w3BYBz50Jvy for ; Tue, 7 Nov 2023 08:21:20 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from mailout.qeng-ho.org (mailout.qeng-ho.org [217.155.128.244]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4SPh4w12Spz4fb0 for ; Tue, 7 Nov 2023 08:21:20 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Authentication-Results: mx1.freebsd.org; none Received: from [IPV6:2a02:8010:64c9:1::2] (unknown [IPv6:2a02:8010:64c9:1::2]) by mailout.qeng-ho.org (Postfix) with ESMTP id 691F5F6A13; Tue, 7 Nov 2023 08:21:12 +0000 (GMT) Message-ID: <48b15ea2-3fd5-4994-aace-f0b8d7dc6ede@qeng-ho.org> Date: Tue, 7 Nov 2023 07:21:03 -0100 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Trying to replace a bashism in bourne sh Content-Language: en-GB To: D'Arcy Cain , freebsd-questions@freebsd.org References: <8cdcb170-1c54-464b-aa89-c89ca98c86ca@druid.net> From: Arthur Chance In-Reply-To: <8cdcb170-1c54-464b-aa89-c89ca98c86ca@druid.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:13037, ipnet:217.155.0.0/16, country:GB] X-Rspamd-Queue-Id: 4SPh4w12Spz4fb0 On 06/11/2023 18:45, D'Arcy Cain wrote: > I need to do this; > >   ifconfig_eth3="inet $((16#c0a8c0${me} + 100))/24" > > Problem is that I need to do this at boot time but then it runs as > bourne sh.  Does anyone have an equivalent for sh? I'm not totally familiar with bash but that (16#c0a8c0) is a hexadecimal number equivalent to an address triplet 192.168.192. I'd guess ${me} is also a 2 digit hex value and for some reason 100 is added. The whole thing is assembling an IPv4 CIDR network address (the /24 is the netmask bit). Try something along the lines of ifconfig_eth3="192.168.192."$((me_in_decimal+100))"/24" if you can arrange for ${me} to be specified in decimal rather than hex. If you can't then something like ifconfig_eth3="192.168.192."$(hex_to_decimal_plus_100 ${me})"/24" where implementing the function hex_to_decimal_plus_100 is left as an exercise for the reader. :-) -- We build our computer systems the way we build our cities; over time, without a plan, on top of ruins. — Ellen Ullman