all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Examining the output of a shell command?
@ 2015-06-28 12:47 Raffaele Ricciardi
  2015-06-28 13:57 ` Pascal J. Bourguignon
       [not found] ` <mailman.5831.1435499861.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Raffaele Ricciardi @ 2015-06-28 12:47 UTC (permalink / raw
  To: help-gnu-emacs

I would like to analyse the escape sequences emitted by a shell
command. I have tried with `shell-command` and
`shell-command-to-string`, but escape sequences are stripped away.

Thank you.


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

* Re: Examining the output of a shell command?
  2015-06-28 12:47 Examining the output of a shell command? Raffaele Ricciardi
@ 2015-06-28 13:57 ` Pascal J. Bourguignon
       [not found] ` <mailman.5831.1435499861.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Pascal J. Bourguignon @ 2015-06-28 13:57 UTC (permalink / raw
  To: help-gnu-emacs

Raffaele Ricciardi <rfflrccrd@gmail.com> writes:

> I would like to analyse the escape sequences emitted by a shell
> command. I have tried with `shell-command` and
> `shell-command-to-string`, but escape sequences are stripped away.

Nope. Try a better lie.

(shell-command-to-string "echo $RED hello $NORMAL")
--> "[31m hello [0m
"

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk




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

* Re: Examining the output of a shell command?
       [not found] ` <mailman.5831.1435499861.904.help-gnu-emacs@gnu.org>
@ 2015-06-28 14:03   ` Dan Espen
  2015-06-28 14:20     ` Michael Heerdegen
       [not found]     ` <mailman.5833.1435501234.904.help-gnu-emacs@gnu.org>
  2015-06-28 14:31   ` Raffaele Ricciardi
  2015-06-29 11:26   ` Raffaele Ricciardi
  2 siblings, 2 replies; 19+ messages in thread
From: Dan Espen @ 2015-06-28 14:03 UTC (permalink / raw
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> Raffaele Ricciardi <rfflrccrd@gmail.com> writes:
>
>> I would like to analyse the escape sequences emitted by a shell
>> command. I have tried with `shell-command` and
>> `shell-command-to-string`, but escape sequences are stripped away.
>
> Nope. Try a better lie.
>
> (shell-command-to-string "echo $RED hello $NORMAL")
> --> "[31m hello [0m
> "

Maybe the OP doesn't realize that some programs that output
escape sequences won't do so when run as an Emacs shell command.

/bin/ls being a good example.

In that case, run:

/bin/ls --color

as an Emacs shell command.


-- 
Dan Espen


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

* Re: Examining the output of a shell command?
  2015-06-28 14:03   ` Dan Espen
@ 2015-06-28 14:20     ` Michael Heerdegen
       [not found]     ` <mailman.5833.1435501234.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Michael Heerdegen @ 2015-06-28 14:20 UTC (permalink / raw
  To: help-gnu-emacs

Dan Espen <despen@verizon.net> writes:

> Maybe the OP doesn't realize that some programs that output
> escape sequences won't do so when run as an Emacs shell command.
>
> /bin/ls being a good example.
>
> In that case, run:
>
> /bin/ls --color
>
> as an Emacs shell command.

I guess programs like "ls" check the TERM environment variable.

Try:

(setenv "TERM" "xterm")

(shell-command-to-string "ls --color")


Michael.




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

* Re: Examining the output of a shell command?
       [not found] ` <mailman.5831.1435499861.904.help-gnu-emacs@gnu.org>
  2015-06-28 14:03   ` Dan Espen
@ 2015-06-28 14:31   ` Raffaele Ricciardi
  2015-06-28 14:55     ` Eli Zaretskii
                       ` (2 more replies)
  2015-06-29 11:26   ` Raffaele Ricciardi
  2 siblings, 3 replies; 19+ messages in thread
From: Raffaele Ricciardi @ 2015-06-28 14:31 UTC (permalink / raw
  To: help-gnu-emacs

On 28/06/15 15:57, Pascal J. Bourguignon wrote:
> (shell-command-to-string "echo $RED hello $NORMAL")
> --> "[31m hello [0m
> "

Here is:

(shell-command-to-string "echo $RED hello $NORMAL")
--> "hello
"

Tried with GNU Emacs 24.5.1:
  - `emacs -Q` (started from a shell where $RED and $NORMAL are defined)
  - M-: (shell-command-to-string "echo $RED hello $NORMAL") RET

Tried with `emacs -nw -Q`, too, in case was a GUI problem.




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

* Re: Examining the output of a shell command?
  2015-06-28 14:31   ` Raffaele Ricciardi
@ 2015-06-28 14:55     ` Eli Zaretskii
       [not found]     ` <mailman.5839.1435503359.904.help-gnu-emacs@gnu.org>
  2015-06-28 15:52     ` Pascal J. Bourguignon
  2 siblings, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2015-06-28 14:55 UTC (permalink / raw
  To: help-gnu-emacs

> From: Raffaele Ricciardi <rfflrccrd@gmail.com>
> Date: Sun, 28 Jun 2015 16:31:29 +0200
> 
> On 28/06/15 15:57, Pascal J. Bourguignon wrote:
> > (shell-command-to-string "echo $RED hello $NORMAL")
> > --> "[31m hello [0m
> > "
> 
> Here is:
> 
> (shell-command-to-string "echo $RED hello $NORMAL")
> --> "hello
> "

Check your shell init files.



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

* Re: Examining the output of a shell command?
       [not found]     ` <mailman.5839.1435503359.904.help-gnu-emacs@gnu.org>
@ 2015-06-28 15:03       ` Raffaele Ricciardi
  2015-06-28 15:43         ` Eli Zaretskii
       [not found]         ` <mailman.5843.1435506194.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Raffaele Ricciardi @ 2015-06-28 15:03 UTC (permalink / raw
  To: help-gnu-emacs

On 28/06/15 16:55, Eli Zaretskii wrote:
>> (shell-command-to-string "echo $RED hello $NORMAL")
>> --> "hello
>> "
>
> Check your shell init files.

I did that already:

    $ echo $RED
    \[\e[1;31m

Another puzzling behaviour:

    $ echo $RED
    \[\e[1;31m
    $ emacs -nw -Q
    M-: (getenv "RED") RET
    --> nil

What's up?  I am using Bash 4.3.30.



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

* Re: Examining the output of a shell command?
  2015-06-28 15:03       ` Raffaele Ricciardi
@ 2015-06-28 15:43         ` Eli Zaretskii
       [not found]         ` <mailman.5843.1435506194.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2015-06-28 15:43 UTC (permalink / raw
  To: help-gnu-emacs

> From: Raffaele Ricciardi <rfflrccrd@gmail.com>
> Date: Sun, 28 Jun 2015 17:03:52 +0200
> 
> On 28/06/15 16:55, Eli Zaretskii wrote:
> >> (shell-command-to-string "echo $RED hello $NORMAL")
> >> --> "hello
> >> "
> >
> > Check your shell init files.
> 
> I did that already:
> 
>     $ echo $RED
>     \[\e[1;31m
> 
> Another puzzling behaviour:
> 
>     $ echo $RED
>     \[\e[1;31m
>     $ emacs -nw -Q
>     M-: (getenv "RED") RET
>     --> nil

Did you "export RED"?

Anyway, what I wanted to point out was that when you invoke the shell
from Emacs, it is a non-interactive session, which might get different
settings.



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

* Re: Examining the output of a shell command?
       [not found]         ` <mailman.5843.1435506194.904.help-gnu-emacs@gnu.org>
@ 2015-06-28 15:51           ` Raffaele Ricciardi
  0 siblings, 0 replies; 19+ messages in thread
From: Raffaele Ricciardi @ 2015-06-28 15:51 UTC (permalink / raw
  To: help-gnu-emacs

On 28/06/15 17:43, Eli Zaretskii wrote:
>> Another puzzling behaviour:
>>
>>      $ echo $RED
>>      \[\e[1;31m
>>      $ emacs -nw -Q
>>      M-: (getenv "RED") RET
>>      --> nil
>
> Did you "export RED"?

This.  I didn't.

> Anyway, what I wanted to point out was that when you invoke the shell
> from Emacs, it is a non-interactive session, which might get different
> settings.

Right.  I will look into it.


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

* Re: Examining the output of a shell command?
  2015-06-28 14:31   ` Raffaele Ricciardi
  2015-06-28 14:55     ` Eli Zaretskii
       [not found]     ` <mailman.5839.1435503359.904.help-gnu-emacs@gnu.org>
@ 2015-06-28 15:52     ` Pascal J. Bourguignon
  2015-06-29  1:53       ` Emanuel Berg
       [not found]       ` <mailman.5887.1435542902.904.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 19+ messages in thread
From: Pascal J. Bourguignon @ 2015-06-28 15:52 UTC (permalink / raw
  To: help-gnu-emacs

Raffaele Ricciardi <rfflrccrd@gmail.com> writes:

> On 28/06/15 15:57, Pascal J. Bourguignon wrote:
>> (shell-command-to-string "echo $RED hello $NORMAL")
>> --> "[31m hello [0m
>> "
>
> Here is:
>
> (shell-command-to-string "echo $RED hello $NORMAL")
> --> "hello
> "

Of course, you need to define RED and NORMAL in your .bashrc!
You may do so by sourcing: 
http://git.informatimago.com/viewgit/?a=viewblob&p=public/bin&h=5cd80cb6bfe405bcc4f9cf7c4f857845b31d1830&hb=08a0ed1597b44dbb32057924837b1a1aeb4a8d61&f=ansi-codes


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


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

* Re: Examining the output of a shell command?
       [not found]     ` <mailman.5833.1435501234.904.help-gnu-emacs@gnu.org>
@ 2015-06-28 17:17       ` Dan Espen
  2015-06-28 18:28         ` Michael Heerdegen
  2015-06-29  1:39         ` Barry Margolin
  0 siblings, 2 replies; 19+ messages in thread
From: Dan Espen @ 2015-06-28 17:17 UTC (permalink / raw
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Dan Espen <despen@verizon.net> writes:
>
>> Maybe the OP doesn't realize that some programs that output
>> escape sequences won't do so when run as an Emacs shell command.
>>
>> /bin/ls being a good example.
>>
>> In that case, run:
>>
>> /bin/ls --color
>>
>> as an Emacs shell command.
>
> I guess programs like "ls" check the TERM environment variable.
>
> Try:
>
> (setenv "TERM" "xterm")

I doubt $TERM is the key.
/bin/ls knows when it is interactive.

> (shell-command-to-string "ls --color")

This will show escape sequences regardless of $TERM.
It did for me with the Emacs default value "dumb".

-- 
Dan Espen


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

* Re: Examining the output of a shell command?
  2015-06-28 17:17       ` Dan Espen
@ 2015-06-28 18:28         ` Michael Heerdegen
  2015-06-29  1:39         ` Barry Margolin
  1 sibling, 0 replies; 19+ messages in thread
From: Michael Heerdegen @ 2015-06-28 18:28 UTC (permalink / raw
  To: help-gnu-emacs

Dan Espen <despen@verizon.net> writes:

> > (shell-command-to-string "ls --color")
>
> This will show escape sequences regardless of $TERM.
> It did for me with the Emacs default value "dumb".

Mmh, not for me.  I don't know much about this.


Michael.




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

* Re: Examining the output of a shell command?
  2015-06-28 17:17       ` Dan Espen
  2015-06-28 18:28         ` Michael Heerdegen
@ 2015-06-29  1:39         ` Barry Margolin
  1 sibling, 0 replies; 19+ messages in thread
From: Barry Margolin @ 2015-06-29  1:39 UTC (permalink / raw
  To: help-gnu-emacs

In article <mmpa5e$ma0$1@dont-email.me>, Dan Espen <despen@verizon.net> 
wrote:

> Michael Heerdegen <michael_heerdegen@web.de> writes:
> 
> > Dan Espen <despen@verizon.net> writes:
> >
> >> Maybe the OP doesn't realize that some programs that output
> >> escape sequences won't do so when run as an Emacs shell command.
> >>
> >> /bin/ls being a good example.
> >>
> >> In that case, run:
> >>
> >> /bin/ls --color
> >>
> >> as an Emacs shell command.
> >
> > I guess programs like "ls" check the TERM environment variable.
> >
> > Try:
> >
> > (setenv "TERM" "xterm")
> 
> I doubt $TERM is the key.
> /bin/ls knows when it is interactive.

What they often check is whether stdout is connected to a terminal.

> > (shell-command-to-string "ls --color")
> 
> This will show escape sequences regardless of $TERM.
> It did for me with the Emacs default value "dumb".

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: Examining the output of a shell command?
  2015-06-28 15:52     ` Pascal J. Bourguignon
@ 2015-06-29  1:53       ` Emanuel Berg
       [not found]       ` <mailman.5887.1435542902.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2015-06-29  1:53 UTC (permalink / raw
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:

> Of course, you need to define RED and NORMAL in your
> .bashrc!

Try this:

    $ export NORMAL="[0m"
    $ emacs -Q --batch --eval '(message (shell-command-to-string "echo $NORMAL"))'

    [0m

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: Examining the output of a shell command?
       [not found]       ` <mailman.5887.1435542902.904.help-gnu-emacs@gnu.org>
@ 2015-06-29  8:13         ` Pascal J. Bourguignon
  0 siblings, 0 replies; 19+ messages in thread
From: Pascal J. Bourguignon @ 2015-06-29  8:13 UTC (permalink / raw
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> "Pascal J. Bourguignon" <pjb@informatimago.com>
> writes:
>
>> Of course, you need to define RED and NORMAL in your
>> .bashrc!
>
> Try this:
>
>     $ export NORMAL="[0m"
>     $ emacs -Q --batch --eval '(message (shell-command-to-string "echo $NORMAL"))'
>
>     [0m

Well you need to insert an escape: 

   export NORMAL="[0m"

Type C-q ESC in emacs, or C-v ESC in the terminal, before [0m.

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


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

* Re: Examining the output of a shell command?
       [not found] ` <mailman.5831.1435499861.904.help-gnu-emacs@gnu.org>
  2015-06-28 14:03   ` Dan Espen
  2015-06-28 14:31   ` Raffaele Ricciardi
@ 2015-06-29 11:26   ` Raffaele Ricciardi
  2015-06-29 12:08     ` Pascal J. Bourguignon
                       ` (2 more replies)
  2 siblings, 3 replies; 19+ messages in thread
From: Raffaele Ricciardi @ 2015-06-29 11:26 UTC (permalink / raw
  To: help-gnu-emacs

On 28/06/15 15:57, Pascal J. Bourguignon wrote:
 > (shell-command-to-string "echo $RED hello $NORMAL")
 > --> "[31m hello [0m> "

Hence, how could I capture a colorized output in Emacs as in a Bash
session?

Below is a Bash script that recursively searches "*.el" files for the
string "defun" and highlights matches (the complex `find` call is the
shell command generated by `M-x rgrep` for the same task):

     #!/bin/bash

     export GREP_COLORS="mt=01;31:fn=:ln=:bn=:se=:sl=:cx=:ne"
     export GREP_OPTIONS="--color=auto"
     find . -type d \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o 
-path \*/MCVS -o -path \*/.svn -o -path \*/.git -o -path \*/.hg -o -path 
\*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) 
-prune -o \! -type d \( -name \*_flymake.\* -o -name .\#\* -o -name \*.o 
-o -name \*\~ -o -name \*.bin -o -name \*.lbin -o -name \*.so -o -name 
\*.a -o -name \*.ln -o -name \*.blg -o -name \*.bbl -o -name \*.elc -o 
-name \*.lof -o -name \*.glo -o -name \*.idx -o -name \*.lot -o -name 
\*.fmt -o -name \*.tfm -o -name \*.class -o -name \*.fas -o -name \*.lib 
-o -name \*.mem -o -name \*.x86f -o -name \*.sparcf -o -name \*.dfsl -o 
-name \*.pfsl -o -name \*.d64fsl -o -name \*.p64fsl -o -name \*.lx64fsl 
-o -name \*.lx32fsl -o -name \*.dx64fsl -o -name \*.dx32fsl -o -name 
\*.fx64fsl -o -name \*.fx32fsl -o -name \*.sx64fsl -o -name \*.sx32fsl 
-o -name \*.wx64fsl -o -name \*.wx32fsl -o -name \*.fasl -o -name 
\*.ufsl -o -name \*.fsl -o -name \*.dxl -o -name \*.lo -o -name \*.la -o 
-name \*.gmo -o -name \*.mo -o -name \*.toc -o -name \*.aux -o -name 
\*.cp -o -name \*.fn -o -name \*.ky -o -name \*.pg -o -name \*.tp -o 
-name \*.vr -o -name \*.cps -o -name \*.fns -o -name \*.kys -o -name 
\*.pgs -o -name \*.tps -o -name \*.vrs -o -name \*.pyc -o -name \*.pyo 
\) -prune -o -type f \( -iname \*.el \) -exec grep -i -n -e defun 
/dev/null {} +

I have tested the above Bash script with `bash --noprofile --norc` as
well, to disable any initialization.  As far as i can tell, Emacs is
running Bash -- `(getenv "SHELL")` returns "/bin/bash" -- without any
initialization scripts -- `(getenv "BASH_ENV")` returns `nil`.

Below is an Emacs Lisp function that returns the output of the same
shell command as a string:

     (defun emacs-grep-test ()
       "Return the output of the `grep` program."
       (let ((process-environment (copy-list process-environment)))
         (setenv "GREP_COLORS" "mt=01;31:fn=:ln=:bn=:se=:sl=:cx=:ne")
         (setenv "GREP_OPTIONS" "--color=auto")
         (shell-command-to-string "find . -type d \\( -path \\*/SCCS -o 
-path \\*/RCS -o -path \\*/CVS -o -path \\*/MCVS -o -path \\*/.svn -o 
-path \\*/.git -o -path \\*/.hg -o -path \\*/.bzr -o -path \\*/_MTN -o 
-path \\*/_darcs -o -path \\*/\\{arch\\} \\) -prune -o \\! -type d \\( 
-name \\*_flymake.\\* -o -name .\\#\\* -o -name \\*.o -o -name \\*\\~ -o 
-name \\*.bin -o -name \\*.lbin -o -name \\*.so -o -name \\*.a -o -name 
\\*.ln -o -name \\*.blg -o -name \\*.bbl -o -name \\*.elc -o -name 
\\*.lof -o -name \\*.glo -o -name \\*.idx -o -name \\*.lot -o -name 
\\*.fmt -o -name \\*.tfm -o -name \\*.class -o -name \\*.fas -o -name 
\\*.lib -o -name \\*.mem -o -name \\*.x86f -o -name \\*.sparcf -o -name 
\\*.dfsl -o -name \\*.pfsl -o -name \\*.d64fsl -o -name \\*.p64fsl -o 
-name \\*.lx64fsl -o -name \\*.lx32fsl -o -name \\*.dx64fsl -o -name 
\\*.dx32fsl -o -name \\*.fx64fsl -o -name \\*.fx32fsl -o -name 
\\*.sx64fsl -o -name \\*.sx32fsl -o -name \\*.wx64fsl -o -name 
\\*.wx32fsl -o -name \\*.fasl -o -name \\*.ufsl -o -name \\*.fsl -o 
-name \\*.dxl -o -name \\*.lo -o -name \\*.la -o -name \\*.gmo -o -name 
\\*.mo -o -name \\*.toc -o -name \\*.aux -o -name \\*.cp -o -name \\*.fn 
-o -name \\*.ky -o -name \\*.pg -o -name \\*.tp -o -name \\*.vr -o -name 
\\*.cps -o -name \\*.fns -o -name \\*.kys -o -name \\*.pgs -o -name 
\\*.tps -o -name \\*.vrs -o -name \\*.pyc -o -name \\*.pyo \\) -prune -o 
-type f \\( -iname \\*.el \\) -exec grep -i -n -e defun /dev/null {} +")))

However, the string returned by `M-: (emacs-grep-test) RET` does not
contain escape sequences to colorize the output, as I would expect.


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

* Re: Examining the output of a shell command?
  2015-06-29 11:26   ` Raffaele Ricciardi
@ 2015-06-29 12:08     ` Pascal J. Bourguignon
  2015-06-29 14:51     ` Eli Zaretskii
       [not found]     ` <mailman.5928.1435589507.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 19+ messages in thread
From: Pascal J. Bourguignon @ 2015-06-29 12:08 UTC (permalink / raw
  To: help-gnu-emacs

Raffaele Ricciardi <rfflrccrd@gmail.com> writes:

> On 28/06/15 15:57, Pascal J. Bourguignon wrote:
>> (shell-command-to-string "echo $RED hello $NORMAL")
>> --> "[31m hello [0m> "
>
> Hence, how could I capture a colorized output in Emacs as in a Bash
> session?

This is an entirely different question, isn't it.

In *shell* and other comint based modes, you can activate interpretion
of ANSI escape codes for colorizing with 
M-x ansi-color-for-comint-mode-on RET

You can process the string with ansi-color-apply:

(ansi-color-apply
 (shell-command-to-string "echo $RED hello $YELLOW world $NORMAL"))
--> #(" hello  world 
" 0 7 (font-lock-face (foreground-color . "red")) 7 14 (font-lock-face (foreground-color . "yellow")))

(insert (ansi-color-apply
          (shell-command-to-string "echo $RED hello $YELLOW world $NORMAL")))
 hello  world 
  ^red    ^yellow
--> nil


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


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

* Re: Examining the output of a shell command?
  2015-06-29 11:26   ` Raffaele Ricciardi
  2015-06-29 12:08     ` Pascal J. Bourguignon
@ 2015-06-29 14:51     ` Eli Zaretskii
       [not found]     ` <mailman.5928.1435589507.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2015-06-29 14:51 UTC (permalink / raw
  To: help-gnu-emacs

> From: Raffaele Ricciardi <rfflrccrd@gmail.com>
> Date: Mon, 29 Jun 2015 13:26:38 +0200
> 
> Hence, how could I capture a colorized output in Emacs as in a Bash
> session?
> 
> Below is a Bash script that recursively searches "*.el" files for the
> string "defun" and highlights matches (the complex `find` call is the
> shell command generated by `M-x rgrep` for the same task):
> 
>      #!/bin/bash
> 
>      export GREP_COLORS="mt=01;31:fn=:ln=:bn=:se=:sl=:cx=:ne"
>      export GREP_OPTIONS="--color=auto"
                                    ^^^^
Did you try with --color=always?



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

* Re: Examining the output of a shell command?
       [not found]     ` <mailman.5928.1435589507.904.help-gnu-emacs@gnu.org>
@ 2015-06-29 15:56       ` Raffaele Ricciardi
  0 siblings, 0 replies; 19+ messages in thread
From: Raffaele Ricciardi @ 2015-06-29 15:56 UTC (permalink / raw
  To: help-gnu-emacs

On 29/06/15 16:51, Eli Zaretskii wrote:
>>       #!/bin/bash
>>
>>       export GREP_COLORS="mt=01;31:fn=:ln=:bn=:se=:sl=:cx=:ne"
>>       export GREP_OPTIONS="--color=auto"
>                                      ^^^^
> Did you try with --color=always?

This.  Thank you.

And yet, in my tests, apparently Emacs was calling `grep` with 
"--color=auto" instead.  But maybe I was missing some other settings.
Never mind.


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

end of thread, other threads:[~2015-06-29 15:56 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-28 12:47 Examining the output of a shell command? Raffaele Ricciardi
2015-06-28 13:57 ` Pascal J. Bourguignon
     [not found] ` <mailman.5831.1435499861.904.help-gnu-emacs@gnu.org>
2015-06-28 14:03   ` Dan Espen
2015-06-28 14:20     ` Michael Heerdegen
     [not found]     ` <mailman.5833.1435501234.904.help-gnu-emacs@gnu.org>
2015-06-28 17:17       ` Dan Espen
2015-06-28 18:28         ` Michael Heerdegen
2015-06-29  1:39         ` Barry Margolin
2015-06-28 14:31   ` Raffaele Ricciardi
2015-06-28 14:55     ` Eli Zaretskii
     [not found]     ` <mailman.5839.1435503359.904.help-gnu-emacs@gnu.org>
2015-06-28 15:03       ` Raffaele Ricciardi
2015-06-28 15:43         ` Eli Zaretskii
     [not found]         ` <mailman.5843.1435506194.904.help-gnu-emacs@gnu.org>
2015-06-28 15:51           ` Raffaele Ricciardi
2015-06-28 15:52     ` Pascal J. Bourguignon
2015-06-29  1:53       ` Emanuel Berg
     [not found]       ` <mailman.5887.1435542902.904.help-gnu-emacs@gnu.org>
2015-06-29  8:13         ` Pascal J. Bourguignon
2015-06-29 11:26   ` Raffaele Ricciardi
2015-06-29 12:08     ` Pascal J. Bourguignon
2015-06-29 14:51     ` Eli Zaretskii
     [not found]     ` <mailman.5928.1435589507.904.help-gnu-emacs@gnu.org>
2015-06-29 15:56       ` Raffaele Ricciardi

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.