From owner-freebsd-questions@freebsd.org Wed Feb 1 15:50:11 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE461CCBB6C for ; Wed, 1 Feb 2017 15:50:11 +0000 (UTC) (envelope-from roger@qxxy.com) Received: from mail-ua0-x22d.google.com (mail-ua0-x22d.google.com [IPv6:2607:f8b0:400c:c08::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8D9BD1A09 for ; Wed, 1 Feb 2017 15:50:11 +0000 (UTC) (envelope-from roger@qxxy.com) Received: by mail-ua0-x22d.google.com with SMTP id 35so299019334uak.1 for ; Wed, 01 Feb 2017 07:50:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qxxy.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=EFTWGjO7IuoDGSj2NVeslVvW5h7qUtrn0uN4owjUBy0=; b=OsWkSZSe9rM807MFLpAkj9FfVYDGB4fStz3ueSMcw7dg0fDLkYEBuMIbREMmkAIMb0 NpkQLapIduj4OjMskvq9p+4kKfKCp5aqORZZyIby7ZzMTIpy1rYduqXa16iSnom8yYL7 EEIecrNWsd0G/V8qxu82+C6h9Rgk7QflXSitc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=EFTWGjO7IuoDGSj2NVeslVvW5h7qUtrn0uN4owjUBy0=; b=gH4GvYl/2mkrv5yvg+1UPyXVPnNJUpcDpieaHJdjGm4WfAqCrFWqrHhklTOLA94aq2 H0hA7f0dsage2g+SmQmXLdVKmt9KzmGYb1EuSr4tMHpKZdxjJnVrXpCAV1P/UR4QFpP5 LAPQLd4W7xfzlE8pGlBEL5vDLF9bLifwc1L/rIuFdd2Syeb1C12gOUTUgc0rQxV7wpaW 6wzHmxgY3ck9B/meuuiexm+8MCbo+T0ssKvXEYOJI8t+d4SCC8Rit4v6QSyYetGfRr9N t8DAwCTofgPyysGDjlUgTiRVqy2JHaCBwT7di/AwSBdR7dT8odYbhGYZgCtdGx1tWbDj rY5Q== X-Gm-Message-State: AIkVDXI/MpmdGZr35AIb+jOCIGK+pJWnprCVMYVDUZrq5Y6EzvYgqz0DobFuJrTcgVPA1cKGJm73Mj4b44HTSg== X-Received: by 10.176.70.69 with SMTP id z5mr1353885uab.64.1485964210573; Wed, 01 Feb 2017 07:50:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.11.1 with HTTP; Wed, 1 Feb 2017 07:49:30 -0800 (PST) X-Originating-IP: [50.90.149.220] In-Reply-To: References: <20170131161824.a9f1ef46.freebsd@edvax.de> <20170131185103.7f911dfb.freebsd@edvax.de> <5f51e2c3bdb8a20c6a7786c2b345c957.squirrel@webmail.harte-lyne.ca> <20170201014858.eec196d0.freebsd@edvax.de> From: Roger Pate Date: Wed, 1 Feb 2017 10:49:30 -0500 Message-ID: Subject: Re: Variable assignment in sh To: Manish Jain Cc: "freebsd-questions@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Feb 2017 15:50:11 -0000 On Wed, Feb 1, 2017 at 10:23 AM, Manish Jain wrote: > On 02/01/2017 08:36 PM, Roger Pate wrote: >> Most often, but not always, if I need something bash has and /bin/sh >> lacks, it's time to write that script in a different language. :P > > Generally, FreeBSD community is averse to bash scritpting. But then sh > lacks array support, which is where bash and zsh do wonderfully well. Not just FreeBSD community, but I won't belabor the point. In particular about arrays, remember that sh does support one array well: $@, both global and per-function. If two arrays are needed, but one can be setup in a for loop (useful for globbing files) or list of lines/NUL-terminated-items (pipe into a while loop or process xargs-like), then you are also good to go. > Generally again, I am averse to most Linuxisms, but bash is simply way > too much convenience to ignore. I used to believe so too, but now I am happier writing more complex scripts in Python. Around the same time, I coincidentally switched my interactive shell from bash to zsh (though I don't use zsh for scripting), and also recommend that.