From patchwork Wed Jul 10 19:58:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clement Chauplannaz X-Patchwork-Id: 2825896 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 608149F756 for ; Wed, 10 Jul 2013 19:58:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5226E20136 for ; Wed, 10 Jul 2013 19:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D5ED20121 for ; Wed, 10 Jul 2013 19:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754102Ab3GJT6W (ORCPT ); Wed, 10 Jul 2013 15:58:22 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:58102 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754051Ab3GJT6V (ORCPT ); Wed, 10 Jul 2013 15:58:21 -0400 Received: by mail-wg0-f49.google.com with SMTP id a12so6196567wgh.4 for ; Wed, 10 Jul 2013 12:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=eiOUYvH30Px1RjWHCcnHoaVTuy11qnU0j48BtHv9324=; b=QbsWXKByj3ScsCjUu+vatHtxoVd2xK6P7z1N2OTz6xaqbW3OG7zwGV5aekL1nyZPXb U8KO2HVtthuV5mUVok/JSm4ggU4K5Y7P2IpnDcKuS9ANu7bTT+b9iFP+Nr/C7KJF6GAG HAptDLO6TwbyzXRiyzMU1mNRfEs7x/0VP6Q65EOxWa5dcS7ktpOkM1BjfIa5Vb1QpCp4 wIQZUQ0XHNgen199g6P/OtK0lDwxagJDzbM9fybk50gkjECLZBYBNOu+hxb498rQwpDU P3bzpiv6nanQ8xIuhl5U7kU1CJTsffR8SMnY2iH+zTKoZYedkMout0xtyJ7qPcMcODWQ TceA== X-Received: by 10.180.8.170 with SMTP id s10mr2384353wia.21.1373486300352; Wed, 10 Jul 2013 12:58:20 -0700 (PDT) Received: from localhost.localdomain (129.130.72.86.rev.sfr.net. [86.72.130.129]) by mx.google.com with ESMTPSA id p1sm69388750wix.9.2013.07.10.12.58.18 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 10 Jul 2013 12:58:19 -0700 (PDT) From: Clement Chauplannaz To: linux-kbuild@vger.kernel.org Cc: mmarek@suse.cz, ak@linux.intel.com, yann.morin.1998@free.fr Subject: [PATCH] scripts/config: use sed's POSIX interface Date: Wed, 10 Jul 2013 21:58:08 +0200 Message-Id: <1373486288-715-1-git-send-email-chauplac@gmail.com> X-Mailer: git-send-email 1.8.3.rc1.44.gb387c77.dirty Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Script `config' relies on extensions of `GNU sed', and is thus not working on all Unixes: - in-place edition of files (-i), which can be replaced with a temporary file; - extended-regexps (-r), which can be split into basic regexps; - single-line calls to `a' command, while some implementations require a leading newline before the parameter. Rewrite calls to `sed' program to comply with POSIX interface. Signed-off-by: Clement Chauplannaz --- scripts/config | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/config b/scripts/config index a65ecbb..3fd95eb 100755 --- a/scripts/config +++ b/scripts/config @@ -66,9 +66,14 @@ set_var() { name_re="^($name=|# $name is not set)" before_re="^($before=|# $before is not set)" if test -n "$before" && grep -Eq "$before_re" "$FN"; then - sed -ri "/$before_re/a $new" "$FN" + lf=$'\n' + sed -e "/^$before=/a\\$lf$new$lf" \ + -e "/^# $before is not set/a\\$lf$new$lf" "$FN" >"$FN.swp" + mv "$FN.swp" "$FN" elif grep -Eq "$name_re" "$FN"; then - sed -ri "s:$name_re.*:$new:" "$FN" + sed -e "s:^$name=.*:$new:" \ + -e "s:^# $name is not set:$new:" "$FN" >"$FN.swp" + mv "$FN.swp" "$FN" else echo "$new" >>"$FN" fi @@ -77,7 +82,8 @@ set_var() { undef_var() { local name=$1 - sed -ri "/^($name=|# $name is not set)/d" "$FN" + sed -e "/^$name=/d" -e "/^# $name is not set/d" "$FN" >"$FN.swp" + mv "$FN.swp" "$FN" } if [ "$1" = "--file" ]; then