From patchwork Thu Nov 15 15:32:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Hussey X-Patchwork-Id: 10684633 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEF1C17F3 for ; Thu, 15 Nov 2018 15:32:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF1232CB6A for ; Thu, 15 Nov 2018 15:32:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B39F42CB73; Thu, 15 Nov 2018 15:32:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E6F62CB6B for ; Thu, 15 Nov 2018 15:32:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388019AbeKPBlK (ORCPT ); Thu, 15 Nov 2018 20:41:10 -0500 Received: from mail-vs1-f66.google.com ([209.85.217.66]:34211 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387839AbeKPBlK (ORCPT ); Thu, 15 Nov 2018 20:41:10 -0500 Received: by mail-vs1-f66.google.com with SMTP id y27so11935632vsi.1 for ; Thu, 15 Nov 2018 07:32:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ci0yI2eAgHJF3oqaMOKVwk4gAIJk3ccAmKAbSZE4lw0=; b=ZTkO4XVIipfqy8ySGV1W4F6CUKepVstisXCx8t8MFyzF09RVmPyvLRSpMr5Sq/vVaz ffgsjrvhiovZCOnvJVx7ZbJbym9W7EBaTub1qb3KrMqSDPFn91saOJxET59lW6+1tfr3 z3vWL8d411v3Ly/q2kQbBThCodxPBJ/qVKeJmow3Oms+qjSqyckd/y1lE+Hp7/0wUk0M PG5vVz/qZKaZWtM+wzE315SmLryimf7GW+7iKZjroTZsZ/WaNZqu0C8NsjSSAVRYBlS4 BhdT1kemKIJuKntwbQiJgxHWsyNUjBRqTJqh8/DQ7e8OKSVx8unXZqDsTsC4QVyMWEQ/ KMlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ci0yI2eAgHJF3oqaMOKVwk4gAIJk3ccAmKAbSZE4lw0=; b=p/ZrcAnkAwtlR0gd6SfS7y31frab4qVQXsd7ZveKBQosKvrgoyFZjRds1+xnRSzNKn 5msESWvSjk1isrhofHACkz/4HM6Q3XSbz8NbsqzxNtVmHIA1wvkT01xtFbT6/2sijBvO FkCjcG/OnuP4uKS8c7VRwE4XCjjoMM0389FWTk6KbPN/sjoU0iMw5539FWrNqK3UZXZt /iLnbSifk8QK+6CeHBpGPwq9DFa41DwYe4lYt7jG7b595jpKQoGIsI/i2rf6njieZr9i X7YXKrX4VRLlZ/+fH8s3yhOgT6nrYp8kdUVtoK1xsaC7UB/j1gGqE5PMPk6SGPU1jROR upaQ== X-Gm-Message-State: AGRZ1gJbm3NBLDn43wc0XSUuYYe+iTvKvXwREtfo1yK+eaVvz4ng2X3F wWYetYh6Fh0iOEXylKhxhMlnk6se8/1gFyPOm1mK/TUP X-Google-Smtp-Source: AJdET5fn0EKbl31K2CPicOLTULM3jfnIOyGlUVl4rhfJkWdX2MNMNX1IzBt9RbD6NXJsDKLvwiiAf4MMLk3hcWeqj1A= X-Received: by 2002:a67:48d9:: with SMTP id c86mr2872049vsg.122.1542295971382; Thu, 15 Nov 2018 07:32:51 -0800 (PST) MIME-Version: 1.0 From: Devin Hussey Date: Thu, 15 Nov 2018 10:32:35 -0500 Message-ID: Subject: [PATCH] Make mktokens accept a random TMPDIR, replace `...` with $(...). To: dash@vger.kernel.org Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From b9724fc82eda2b0d164c33ad3e871d38b298d1ad Mon Sep 17 00:00:00 2001 From: Devin Hussey Date: Thu, 15 Nov 2018 10:30:05 -0500 Subject: [PATCH] Make mktokens accept a random TMPDIR, replace `...` with $(...). Sorry about the multiple commits at once. Signed-off-by: Devin Hussey Signed-off-by: Devin Hussey --- src/mktokens | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mktokens b/src/mktokens index cd52241..ec801cc 100644 --- a/src/mktokens +++ b/src/mktokens @@ -37,7 +37,10 @@ # token marks the end of a list. The third column is the name to print in # error messages. -cat > /tmp/ka$$ <<\! +# set TMPDIR if it isn't already +[ -z "${TMPDIR}" ] && TMPDIR="/tmp" + +cat > "${TMPDIR}/ka$$" <<\! TEOF 1 end of file TNL 0 newline TSEMI 0 ";" @@ -68,28 +71,28 @@ TWHILE 0 "while" TBEGIN 0 "{" TEND 1 "}" ! -nl=`wc -l /tmp/ka$$` +nl=$(wc -l "${TMPDIR}/ka$$") exec > token.h -awk '{print "#define " $1 " " NR-1}' /tmp/ka$$ +awk '{print "#define " $1 " " NR-1}' "${TMPDIR}/ka$$" exec > token_vars.h echo ' /* Array indicating which tokens mark the end of a list */ static const char tokendlist[] = {' -awk '{print "\t" $2 ","}' /tmp/ka$$ +awk '{print "\t" $2 ","}' "${TMPDIR}/ka$$" echo '}; static const char *const tokname[] = {' sed -e 's/"/\\"/g' \ -e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \ - /tmp/ka$$ + "${TMPDIR}/ka$$" echo '}; ' -sed 's/"//g' /tmp/ka$$ | awk ' +sed 's/"//g' "${TMPDIR}/ka$$" | awk ' /TNOT/{print "#define KWDOFFSET " NR-1; print ""; print "static const char *const parsekwd[] = {"} /TNOT/,/neverfound/{if (last) print " \"" last "\","; last = $3} END{print " \"" last "\"\n};"}' -rm /tmp/ka$$ +rm "${TMPDIR}/ka$$"