From patchwork Thu May 24 18:20:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Hussey X-Patchwork-Id: 10425313 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.web.codeaurora.org (Postfix) with ESMTP id C2C59602D8 for ; Thu, 24 May 2018 18:21:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDC4E296C9 for ; Thu, 24 May 2018 18:21:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2739296DD; Thu, 24 May 2018 18:21:20 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 09D46296BC for ; Thu, 24 May 2018 18:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970999AbeEXSVR (ORCPT ); Thu, 24 May 2018 14:21:17 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:40626 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970430AbeEXSVO (ORCPT ); Thu, 24 May 2018 14:21:14 -0400 Received: by mail-pg0-f52.google.com with SMTP id l2-v6so1144628pgc.7 for ; Thu, 24 May 2018 11:21:14 -0700 (PDT) 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=3f0/ehe9JvUs/7xEFD4SJzUQ9UkUtg/eAzAC/QH7CoY=; b=GZer3lWMzpLpJ8GyttB/XIc9EuzFhCOTfCMJTJiwZJvJ9JJvcXQucDOUyg6CGks/n7 s6Q6oq8vO/ftE3vz3WBGN82MFpUuHPQWeQh6NZo6fuCj9rIKrg2kDk711Wa5s7axInyg kn8Dae8AaHa0rWpS31HQ0+9+CTpNas0oJekXywEeUPwxhjJBa1AIDn5zNF7QS8S+YJnF 1mDtNG73PuumL/rVpLsff1Pg7GumvjEAS8stNfgPPR0uYeOrcX9vOX+F/l5YAL+WjC6J kVD6YvPkw1wV52ZHsQfs6rbThAGQvk79YzOIhlSCt5QH9GK70uPe4G8t//Rs1CD+xWKN 6kRQ== 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=3f0/ehe9JvUs/7xEFD4SJzUQ9UkUtg/eAzAC/QH7CoY=; b=S+J0/s5vPSDarR53O16XyU1Hw6gc+pFJKOdWmh+VJLtBmV6w3yRm62lxz2KeRXOzf3 rjAI0EsDtN/THZwnox2QPRQr0XmkfMLe/WzJZlST8YGH7Xyqwi6el65aLcAJCNQ3YgoK Bt5V2cSlxSjz5vt9WW71K9ZxpAm7ChwCbYg8ivdV/9doZtgpjZnIFaGjIgt0uYN/buKA Mz2OQC/vlV1qkKZbEpXDW91RttQnAs7tY0zgYX6qOQdy++EpA8IXKgq/HAvrHFLvVWJn mjvj9DXy8R5d8mEOS4XnOVhcLY3sk4ezNGNtPYfVdQ+ZCF+VzK75v98r7SnHDyicLyOX W7PA== X-Gm-Message-State: ALKqPwfSWXs8gaZnf6B2oEdI5rElYcRKsZt8KAziw8jbE+wdRgzrkc/k YT4GOKhePXaIusepnlW0ykC4C96k5tgGDMzzKznFbQ== X-Google-Smtp-Source: AB8JxZpOG3tF5gTRYShQ6ZHhPSLtKBnkGfCDaK+Ysge9760BgdiTJK9PqjubZhPuwtscVgK2O0I86F9f6wzz9OWx7Ow= X-Received: by 2002:a65:484c:: with SMTP id i12-v6mr6812656pgs.162.1527186073508; Thu, 24 May 2018 11:21:13 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:1990:0:0:0:0 with HTTP; Thu, 24 May 2018 11:20:53 -0700 (PDT) From: Devin Hussey Date: Thu, 24 May 2018 14:20:53 -0400 Message-ID: Subject: [PATCH] Fix some portability issues 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 This patch makes Dash more patch-generic. It replaces /tmp with $TMPDIR, uses SYSCONFDIR instead of /etc for the profile path, and includes for fewer implicit declaration warnings. This allows dash to be compiled and run without issues on the very unorthodox Android Termux environment, which has no /etc or writable /tmp. --Devin Hussey From af7daf9f6268c0879d227e8d06cfbc6b46b6fefd Mon Sep 17 00:00:00 2001 From: Devin Hussey Date: Wed, 23 May 2018 12:05:53 -0400 Subject: [PATCH] Fix some portability issues. Signed-off-by: Devin Hussey --- src/Makefile.am | 2 +- src/main.c | 2 +- src/mktokens | 16 ++++++++-------- src/system.h | 1 + 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 46399c7..bbeed15 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,7 +6,7 @@ COMMON_CPPFLAGS = \ -DBSD=1 -DSHELL AM_CFLAGS = $(COMMON_CFLAGS) -AM_CPPFLAGS = $(COMMON_CPPFLAGS) +AM_CPPFLAGS = $(COMMON_CPPFLAGS) -DSYSCONFDIR=$(sysconfdir) AM_CFLAGS_FOR_BUILD = -g -O2 $(COMMON_CFLAGS) AM_CPPFLAGS_FOR_BUILD = $(COMMON_CPPFLAGS) diff --git a/src/main.c b/src/main.c index e8e4256..e83d8e0 100644 --- a/src/main.c +++ b/src/main.c @@ -148,7 +148,7 @@ main(int argc, char **argv) login = procargs(argc, argv); if (login) { state = 1; - read_profile("/etc/profile"); + read_profile(SYSCONFDIR "/profile"); state1: state = 2; read_profile("$HOME/.profile"); diff --git a/src/mktokens b/src/mktokens index cd52241..7eef8cd 100644 --- a/src/mktokens +++ b/src/mktokens @@ -37,7 +37,8 @@ # token marks the end of a list. The third column is the name to print in # error messages. -cat > /tmp/ka$$ <<\! +TMPDIR=${TMPDIR:-/tmp} +cat > $TMPDIR/ka$$ <<\! TEOF 1 end of file TNL 0 newline TSEMI 0 ";" @@ -68,28 +69,27 @@ 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$$ diff --git a/src/system.h b/src/system.h index a8d09b3..6b2e06a 100644 --- a/src/system.h +++ b/src/system.h @@ -29,6 +29,7 @@ #include #include #include +#include #ifndef SSIZE_MAX #define SSIZE_MAX ((ssize_t)((size_t)-1 >> 1))