Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15561

Re: Feature Request: Custom delimeter for single quotes

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: Feature Request: Custom delimeter for single quotes
Date Sun, 3 Nov 2019 01:31:50 -0500
Lines 83
Approved bug-bash@gnu.org
Message-ID <mailman.488.1572762722.13325.bug-bash@gnu.org> (permalink)
References <CAOnw=2J6fse6U=6zofMW7pORp0yTere_DYYSKGS6hf5xK2PuQA@mail.gmail.com> <5DBE6EF9.2000309@tlinx.org> <20421118-fb8b-531a-8dfa-bdb53ebb1a95@archlinux.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gwTKume8Jycgv7j0f3ZcJgDJeEdeS8TCo"
X-Trace usenet.stanford.edu 1572762723 24938 209.51.188.17 (3 Nov 2019 06:32:03 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1572762714; bh=Uw3iqWCEc5aezFbEdpTZEyOWn9vC8TiirsNK4UPuLVM=; h=Subject:To:References:From:Date:In-Reply-To; b=XVw+6R0E83hUKj9uHaPVF+3EEjKqPMMkmaFTA+lnjSilTAMK6BG5m0z0ytbXyxZU/ OI6WCP81Hzj8DIBQzZN6kA4WtEbXWIORUNcq9KpU3uP/Ve/ADADinMOxlquvKvm8GG tOFkG7J9+0UDgFOVRIsV9zKqvuQqKB0QxFedMu7RAslO3obSlgL90LTL+4FTdmgdsF VwDTSBHOAK6qtpJLPg5Y/6oBXy4GPl0AX97NIQXiIrU6YSjTIY2M2/zgctFaFtVzHf ofdWjAp7/0irB2PsywlL4HJZLyAYDFwRVg5bOsBIfCCvCkPEsZFmkrYxP6U0hg0/Qt JiK5tIgCavrVUBO7n0dWu3zPn7eHZsscW66od/JvYrEaeQ3Jv39CtnXj6ByEGlEOCk psHCcLJqWryvhxgALkDepNwvQN8QIHj+IwPWCo8oyom4bdk9OVs1auPWQx1C275ES8 b1Fy0lerZsW2uqLy6AEF6YJJKoL7etIbZPerjsLiRiAUGw+4QlohZZE6jMyvGzyZB6 RbH56kOi4tyGDmXSB0mJ3Pqodenyx///ypkrVQdiHkx12EFevqPytSWQ03jzRzo9kw 2dbc8r5PuPfr0Dw5wGdttZ3NRUn8zVC8nrNDCTtUPeV2xolgIMdzFSWUMpGhsK/9JF ftPo+zJ/Jov7ySfjvLJCCecU=
X-Clacks-Overhead GNU Terry Pratchett
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0
In-Reply-To <5DBE6EF9.2000309@tlinx.org>
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 88.198.91.70
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <20421118-fb8b-531a-8dfa-bdb53ebb1a95@archlinux.org>
X-Mailman-Original-References <CAOnw=2J6fse6U=6zofMW7pORp0yTere_DYYSKGS6hf5xK2PuQA@mail.gmail.com> <5DBE6EF9.2000309@tlinx.org>
Xref csiph.com gnu.bash.bug:15561

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 11/3/19 1:08 AM, L A Walsh wrote:
> I can't say for certain, but is there any reason why this wouldn't
> work?  As long as the user input doesn't match the generated uuid,
> it should be hard to match it as a delimiter...
> 
> I am probably missing something obvious, but this would seem to
> solve your problem, no?
> 
> 
> 
> read usercmd       # or whatever/however you get the command
> 
> delim=$(uuidgen)
> printf -v cmd "sh -c <<'%s'\n%s\n%s\n" "$delim" "$usercmd" "$delim"
> eval $cmd

Leaving aside all the many many MANY problems with what you jokingly
call "shellscripts"... once you have a usercmd variable, why do you need
to printf it into another variable in order to run it (in your existing
shell) via sh -c *AND* eval, with the end result of... evaluating
usercmd, no more, no less?

At any rate, your proposal is simply a syntax error, for two reasons:
- sh -c expects a string, not a stdin redirection
- eval must take a quoted variable in order to correctly handle
  variables with embedded newlines

Given many fine answers were already suggested in this thread, can we
avoid proposing new ones which are both terrible and terrible failures
at even being cursorily tested?

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Feature Request: Custom delimeter for single quotes Eli Schwartz <eschwartz@archlinux.org> - 2019-11-03 01:31 -0500

csiph-web