From owner-svn-src-head@freebsd.org Thu Mar 16 19:17:03 2017 Return-Path: Delivered-To: svn-src-head@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 CBA76D0FA4B for ; Thu, 16 Mar 2017 19:17:03 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-ua0-x232.google.com (mail-ua0-x232.google.com [IPv6:2607:f8b0:400c:c08::232]) (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 816B81D10 for ; Thu, 16 Mar 2017 19:17:03 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-ua0-x232.google.com with SMTP id 72so32304626uaf.3 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=K3471nm1M7gMV06UEmZ7IiS5SqVnocaACE5OAxbp8jkJueg61N4nQMyOD/ghcMbq3+ Ddm1/+eeafeygqvoIaPeH/pUknYNyUv9e11kgu0m6P1sdeMYyWuIrZQJtkfJLrVluqZG GsOx6iDKIXBM5MIcc/Z4j96UKYM9OEw4eGr9teLPLujc9kZAQVqHKV2tODdtdJ1FycNW mA4O7b2NaRGs8T7b6qV4elxWMTtnolNTF0e3TjLZjUdCOW/nFrqw8Km8u4XmO6jGmDHY dTCiE66vDJg0c8my+qhhTbpx9pwbQMPNqH8MxVpAvc3kNvG7VagJ/seJbsBh4a8YNbcS U12g== X-Gm-Message-State: AFeK/H1QuYc1xH28UNxs2nwygek1z2MH/ZR5ugpxWsKwNBrVurnSTdGXcKdR3F5fr1tlUn3+gKCCqq1mOke9Znby 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-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current 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 >