0

I'm using the advice here to setup an alias to convert markdown to man style output using the command,

alias mdless="pandoc -s -f markdown -t man \!* | groff -T utf8 -man | less"

I keep getting the error: pandoc: !*: openFile: does not exist (No such file or directory)

But the command words fine if I just do pandoc -s -f markdown -t man README.md | groff -T utf8 -man | less

Is there something wrong with this bash expansion syntax?

DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119

1 Answers1

3

That example is a tcsh alias not a bash alias. That's why you needed to add the = that the original had to yours to get it to work at all.

The problem is that tcsh (apparently) removes escaping backslashes from history expansion exclamation points that it sees in double quoted strings:

tcsh$ echo "\!*"
!*

Whereas bash (for some reason I've never understood) does not do that:

bash$ echo "\!*"
\!*

I'm not sure you can get an exact duplicate of that alias in bash since I don't think bash will do history expansion on an alias expansion so the closest you can get is a function that takes files as arguments:

mdless() {
    pandoc -s -f markdown -t man "$@" | groff -T utf8 -man | less
}
Etan Reisner
  • 77,877
  • 8
  • 106
  • 148