all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* shell-quote-argument escapes '='
       [not found] <1235716199.473564.1587731751300.ref@mail.yahoo.com>
@ 2020-04-24 12:35 ` R. Diez
  2020-04-24 13:28   ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: R. Diez @ 2020-04-24 12:35 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Hallo all:

I am running a self-compiled Emacs version 26.2 on Ubuntu 18.04.4 LTS. I normally use Bash as a shell.

When I evaluate the following in Emacs:

  (shell-quote-argument "a=b")

I get:

  "a\\=b"

That's wrong, because it does not work in Bash:

  $ echo "a\\=b"
  a\=b

But even if I am getting confused with Emacs' string escaping, echo "a\=b" does not work either.

I am looking for the equivalent in Emacs for Bash' printf "%q" escaping/quoting:

  $ printf "%q" "a=b"
  a=b

I though I might just copy and modify shell-quote-argument, but it is too complicated for my limited Lisp skills.

I do not need any flexibility or configuration, I just need to emulate the behaviour of Bash' printf "%q".

Thanks in advance for any help,
  rdiez



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: shell-quote-argument escapes '='
  2020-04-24 12:35 ` shell-quote-argument escapes '=' R. Diez
@ 2020-04-24 13:28   ` Stefan Monnier
  2020-04-24 16:13     ` Philipp Stephani
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2020-04-24 13:28 UTC (permalink / raw)
  To: help-gnu-emacs

>   (shell-quote-argument "a=b")
>
> I get:
>
>   "a\\=b"

Which is the printed representation of the string that contains
4 characters:

    a\=b

> That's wrong, because it does not work in Bash:
>
>   $ echo "a\\=b"
>   a\=b

You're not supposed to put quotes around nor to double the backslash:

    $ echo a\=b
    a=b
    $


-- Stefan




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: shell-quote-argument escapes '='
  2020-04-24 13:28   ` Stefan Monnier
@ 2020-04-24 16:13     ` Philipp Stephani
  0 siblings, 0 replies; 3+ messages in thread
From: Philipp Stephani @ 2020-04-24 16:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Am Fr., 24. Apr. 2020 um 15:29 Uhr schrieb Stefan Monnier
<monnier@iro.umontreal.ca>:
>
> >   (shell-quote-argument "a=b")
> >
> > I get:
> >
> >   "a\\=b"
>
> Which is the printed representation of the string that contains
> 4 characters:
>
>     a\=b
>
> > That's wrong, because it does not work in Bash:
> >
> >   $ echo "a\\=b"
> >   a\=b
>
> You're not supposed to put quotes around nor to double the backslash:
>
>     $ echo a\=b
>     a=b
>     $
>


Note that those two aren't the same. The command

a=b

sets the variable 'a' to the string 'b'. The command

a\=b

runs a function/command/binary called 'a=b'. So not quoting = (i.e.
replicating the printf %q behavior) would be a breaking change.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-24 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1235716199.473564.1587731751300.ref@mail.yahoo.com>
2020-04-24 12:35 ` shell-quote-argument escapes '=' R. Diez
2020-04-24 13:28   ` Stefan Monnier
2020-04-24 16:13     ` Philipp Stephani

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.