This question is related to the solution nanny provides to the xml beautifying problem on this answer: How to prettify/format an XML buffer?

This works for me on Emacs 24.5 on Windows, but I want to know what does "xmllint --format -" parameter of the shell-command-on-region function mean? Apparently "xmllint --format" does not work and when I run "xmllint --format -" in the Windows shell it waits for my input instead of returning to the command interpreter. I am able to input an xml document data from the console and after pressing Ctrl-z RET get my input beautified back to the console.

I am curious what exactly the role of the trailing dash in the shell command execution string is.

3 Answers 3


A token consisting of a single hyphen character is interpreted as an ordinary non-option argument. By convention, it is used to specify input from or output to the standard input and output streams.

Taken from: https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html

In your case, this means that arguments will come from standard input.

  • I think you meant to say that the input will come from stdin, not the arguments.
    – jtgd
    Feb 18, 2017 at 5:12
  • @jtgd well, technically, the command expects arguments, which represent files it needs to parse. But the way the arguments are delivered is by means of sending some input to this command. So, both statements are true, they just relate to different aspects of what is going on.
    – wvxvw
    Feb 18, 2017 at 13:29

This isn't really an Emacs question, and it's not even really a question about command shells. It's a convention adopted by a fair number of command-line programs that take filenames as command-line arguments. When you specify - as the filename, they instead read from stdin (or write to stdout).

  • And just to be explicit, shell-command-on-region sends the text in the marked region to the specified command via standard input, and therefore the command needs to be told to read from stdin (if that is not already its default behaviour). The command's output on stdout will be read by Emacs and used appropriately.
    – phils
    Feb 15, 2017 at 21:19

... what exactly the role of the trailing dash in the shell command execution ...

It's a parameter that stands for STDIN or STDOUT, depending on context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.