From owner-svn-src-all@freebsd.org Thu Mar 16 19:17:03 2017 Return-Path: Delivered-To: svn-src-all@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 CC399D0FA4C for ; Thu, 16 Mar 2017 19:17:03 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-ua0-x22e.google.com (mail-ua0-x22e.google.com [IPv6:2607:f8b0:400c:c08::22e]) (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 84BCF1D12 for ; Thu, 16 Mar 2017 19:17:03 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-ua0-x22e.google.com with SMTP id q7so32296661uaf.2 for ; Thu, 16 Mar 2017 12:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/m8ypeyE4W7uq8o01whoQuyxmyELIVRoXTwFhFkRYhg=; b=irlnmdbeCmzKZ1KVLiSYjLAr8A6fFvmit/lUtgLcIb8MqAC4OTik+/8Dj2HknPOXZp f17D82mMQ/96M5ZmBeSLeyGDg6xIu/N0yNqfZNVzeIcMRoF/AEMYUVZVWEdKvHqYB1IS SKsfTESIFgWTGyIEdl7mtrGDeU6TiyPy102P7w+GUZ2Z10UKK/2+DOe8AQX9ZBNJzI8/ +amSnUpOVUUGqzzuDW8+75HkvyyJQBs89syBj5ykqSt7TwP/SJbmrldiTRRZ6kLH7/iZ r/2Qxu0dY2BKJj4KGkFj6WlYLM1Kk8mfjIBJ15r1hQWt6i+7CRDBSib3xqU6cxrEuHTv Ofsw== 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=/m8ypeyE4W7uq8o01whoQuyxmyELIVRoXTwFhFkRYhg=; b=TiswpJ3YYS7892ce4TKaMNIp38PUa3nJN4PL8U6B/YkZL4OduHx98jtG7wB3dKG3Eq QEWNFLgOPxHDT1jroY2Zer2Ha34tWmO9qC6oM/zsmgKWYRggN8ppxXeCNEgJnM/aER9M ZIGSh6zZygM7caMhsQnY24vfV1xY4glv6v/B/f0TAWBZ9qE5vbVECr0ganeVr3VSQkbq TuCTzf8wE9pGW/S+3s+2/zHbrjMXMmuAtq4EleJuD04CybhJ4VWv1ownlJoLDUNEKSoV BvLLPrXr0Aa9feA8h9kQVlZQ96QsJRoEtItX696lyz5n6ds8UMc6NNG5wDNn8AMQsx9+ kUwA== X-Gm-Message-State: AFeK/H3t11FYYl6c35tinH36ajCIjr1m5U++UtZbrIWamNGHhRD5lvxQA/7I4Fh8r+m7AIFxeMUP9iAfE25JDIeG X-Received: by 10.159.35.137 with SMTP id 9mr4686566uao.110.1489691822525; Thu, 16 Mar 2017 12:17:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.45.2 with HTTP; Thu, 16 Mar 2017 12:17:02 -0700 (PDT) In-Reply-To: <20170317055036.D27477@besplex.bde.org> References: <201703161640.v2GGes8N033822@repo.freebsd.org> <20170317040832.N26977@besplex.bde.org> <20170317055036.D27477@besplex.bde.org> From: Oliver Pinter Date: Thu, 16 Mar 2017 20:17:02 +0100 Message-ID: Subject: Re: svn commit: r315418 - in head/sys/teken: . libteken To: Bruce Evans Cc: Bruce Evans , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Mar 2017 19:17:03 -0000 On 3/16/17, Bruce Evans wrote: > On Thu, 16 Mar 2017, Oliver Pinter wrote: > >> On 3/16/17, Bruce Evans wrote: >>> On Thu, 16 Mar 2017, Bruce Evans wrote: >>> >>>> Log: >>>> Add teken_256to16() to convert xterm-256 256-color codes to xterm >>>> 16-color >>>> codes. This will be used to fix bright colors. >>>> >>>> Improve teken_256to8(). Use a lookup table instead of calculations. >>>> The >>>> ... >>> >>> A shell script for printing some text color maps is attached. Also a >>> sloppier one for printing some CSI sequences. >>> ... >> >> If I'm not wrong, these scripts where made on OS X. They use \r\n line >> endings, >> and this triggers random cryptic runtime errors: >> >> op@opn /tmp> sh -x sc-vt-CSI >> + printf $'\\033[m\r' >> + printf $'\\033[x\r' >> sc-vt-CSI: 5: Syntax error: word unexpected >> >> The simple fix is to delete the '\r's from the scripts: >> >> cat sc-vt-CSI | tr -d '\r' > trans.sh > > No OS X here. > > It means that some mailers mangle even attachments. > > Shells should probably accept \r\n as newline on systems where this is > not the native newline. Some C compilers do. The problems stats with imgact_shell, you can easily verify this with the following: op@opn /tmp> printf '#\!/bin/sh\r\n' > test.sh op@opn /tmp> chmod +x test.sh op@opn /tmp> ./test.sh ./test.sh: Command not found. op@opn /tmp> sh -x ./test.sh op@opn /tmp> A possible solution would be the following patch: Xdiff --git a/sys/kern/imgact_shell.c b/sys/kern/imgact_shell.c Xindex aaf521cf251..7b3feb20a3c 100644 X--- a/sys/kern/imgact_shell.c X+++ b/sys/kern/imgact_shell.c X@@ -146,7 +146,7 @@ exec_shell_imgact(imgp) X ihp++; X interpb = ihp; X while (ihp < maxp && ((*ihp != ' ') && (*ihp != '\t') && (*ihp != '\n') X- && (*ihp != '\0'))) X+ && (*ihp != '\r') && (*ihp != '\0'))) X ihp++; X interpe = ihp; X if (interpb == interpe) X@@ -162,7 +162,7 @@ exec_shell_imgact(imgp) X while (ihp < maxp && ((*ihp == ' ') || (*ihp == '\t'))) X ihp++; X optb = ihp; X- while (ihp < maxp && ((*ihp != '\n') && (*ihp != '\0'))) X+ while (ihp < maxp && ((*ihp != '\n') && (*ihp != '\r') && (*ihp != '\0'))) X ihp++; X opte = ihp; X if (opte == maxp) this is not tested, even nor compile tested, just a PoC. > > Bruce >