From patchwork Fri Dec 11 11:56:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Perkin X-Patchwork-Id: 7829211 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-dash@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 02161BEEE1 for ; Fri, 11 Dec 2015 11:56:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 211A620570 for ; Fri, 11 Dec 2015 11:56:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04A96204D3 for ; Fri, 11 Dec 2015 11:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753285AbbLKL4t (ORCPT ); Fri, 11 Dec 2015 06:56:49 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:35371 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752902AbbLKL4s (ORCPT ); Fri, 11 Dec 2015 06:56:48 -0500 Received: by mail-wm0-f41.google.com with SMTP id l68so9955991wml.0 for ; Fri, 11 Dec 2015 03:56:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joyent.com; s=google; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=9v57jzSc/iYcTcXH6RjgBeHAHkpayZRp2MeacqmwnPA=; b=PQyWiCSTb58TLQGBioGcKyNyK+kV+FwWDv5O2Qlfl3VWxPTAZvOpcvJAKHwvi52WPU yVbwBJgRfj7ts5Yvn8OtLApL/Yb3BqhII+VEkAROufCmQn+QIbhqDI+NuyX9xQQSyoFM Ebf6Dc48ZllNUYLeXvoQp25JCEjqepkjw0qJw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=9v57jzSc/iYcTcXH6RjgBeHAHkpayZRp2MeacqmwnPA=; b=gTGC0zaTLQifXv8Jsr9r/KSo0Lj6B+7Ks9WdpESvBtScK78PFkqHsIzb2QGJJLoVcY 11aFdln/PWUjliNb6fsXWH7Ifi8SlJToJZbnuxp4ASZgl+OlLLO6+W2oz4b545UfXNWh P8pSM599hQfasnSf0JngwKhzYDyoE1SGxtIcTgipzq90MLh8c/PG+0zre/gqGqltcRdi wO1gYBPEUw/h7dPpb1TE/UUObWFt8Ktzsof6xdb41KyKKGqxg81LB8RmiZmOC31FJAPX ox1VKFv2sS1XrdD1l0g9hqRD09YkliQFYbjKYulAlubm/OfYKolSNDmsExANdednKLPS lAdg== X-Gm-Message-State: ALoCoQmwNkzZyWmI0F2KBqEYZ1yd2Gl8bd53KVRfapQOR/uPFscN2eFOf/R2dKU9M5cTtO/hc5jeBEvIPPcdge/iq5Uadldjug== X-Received: by 10.28.227.212 with SMTP id a203mr5261724wmh.68.1449835007448; Fri, 11 Dec 2015 03:56:47 -0800 (PST) Received: from joyent.com (host86-144-234-20.range86-144.btcentralplus.com. [86.144.234.20]) by smtp.gmail.com with ESMTPSA id s11sm3096126wmb.14.2015.12.11.03.56.45 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Dec 2015 03:56:46 -0800 (PST) Date: Fri, 11 Dec 2015 11:56:43 +0000 From: Jonathan Perkin To: dash@vger.kernel.org Subject: [PATCH] [SHELL] Fix build on Solaris 9 Message-ID: <20151211115623.GA54973@joyent.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure dash can build in a default Solaris 9 or older environment: - Execute scripts with $SHELL rather than /bin/sh, the latter does not support e.g. "if ! .." used by mkbuiltins. - /bin/awk does not support ?: syntax, use explicit statements instead. - /bin/nl requires no spaces between options and arguments. --- src/Makefile.am | 4 ++-- src/mkbuiltins | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 120ffa2..139355e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,13 +46,13 @@ EXTRA_DIST = \ mknodes.c nodetypes nodes.c.pat mksyntax.c mksignames.c token.h token_vars.h: mktokens - sh $^ + $(SHELL) $^ builtins.def: builtins.def.in $(top_builddir)/config.h $(COMPILE) -E -x c -o $@ $< builtins.c builtins.h: mkbuiltins builtins.def - sh $^ + $(SHELL) $^ init.c: mkinit $(dash_CFILES) ./$^ diff --git a/src/mkbuiltins b/src/mkbuiltins index 8c74d6b..b4d6f4e 100644 --- a/src/mkbuiltins +++ b/src/mkbuiltins @@ -84,9 +84,13 @@ awk '{ for (i = 2 ; i <= NF ; i++) { opt = substr($2, 2) $2 = $3 } - printf "\t{ \"%s\", %s, %d },\n", $1, - (opt ~ /n/) ? "NULL" : $2, - (opt ~ /s/) + (opt ~ /[su]/) * 2 + (opt ~ /a/) * 4 + mask = 0 + cmd = $2 + if (opt ~ /n/) { cmd = "NULL" } + if (opt ~ /s/) { mask += 1 } + if (opt ~ /[su]/) { mask += 2 } + if (opt ~ /a/) { mask += 4 } + printf "\t{ \"%s\", %s, %d },\n", $1, cmd, mask }' echo '};' @@ -97,7 +101,7 @@ cat <<\! */ ! -sed 's/ -[a-z]*//' $temp2 | nl -b a -v 0 | +sed 's/ -[a-z]*//' $temp2 | nl -ba -v0 | LC_ALL= LC_COLLATE=C sort -u -k 3,3 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | awk '{ printf "#define %s (builtincmd + %d)\n", $3, $1}'