1

I'm using oh-my-zsh a have the following alias in .zshrc:

alias composer="php -d memory_limit=-1 $(which composer)"

I get the following output:

$ composer
Could not open input file: composer:

And for:

$ which composer
composer: aliased to php -d memory_limit=-1 composer: aliased to php -d memory_limit=-1 composer: aliased to php -d memory_limit=-1 /usr/local/bin/composer
$ zsh --version
zsh 5.2 (x86_64-apple-darwin15.4.0)

Under Linux it works as expected:

$ which composer
composer: aliased to php -d memory_limit=-1 /usr/bin/composer
$ zsh --version
zsh 5.3.1 (x86_64-unknown-linux-gnu)
michalzuber
  • 5,079
  • 2
  • 28
  • 29

2 Answers2

2

This has nothing to do with it being on OS X or Linux, or the usage of screen. It very much looks like you ran the command

alias composer="php -d memory_limit=-1 $(which composer)"

multiple times. which lead to the recursive definition of composer:

composer: aliased to php -d memory_limit=-1 composer: aliased to php -d memory_limit=-1 composer: aliased to php -d memory_limit=-1 /usr/local/bin/composer

Adding line-breaks to make it obvious:

composer: aliased to php -d memory_limit=-1 \
composer: aliased to php -d memory_limit=-1 \
composer: aliased to php -d memory_limit=-1 \
/usr/local/bin/composer

While the first use of which composer will return /usr/local/bin/composer (or a similar path), subsequent uses will return composer: aliased to .... This leads to the error message that the input file composer: (Note the colon) could not be found.

Defining the alias just once will probably work for the most part, but to be safe you can tell which explicitly to look for paths (ignoring builtins, aliases and functions) with the parameter -p:

alias composer="php -d memory_limit=-1 $(which -p composer)"
mklement0
  • 382,024
  • 64
  • 607
  • 775
Adaephon
  • 16,929
  • 1
  • 54
  • 71
  • 1
    Nicely done; a note to non-zsh users: in zsh, `which` is a _builtin_ that also reports the definition of _aliases_. – mklement0 Jun 01 '17 at 13:33
-1

It was an issue with GNU screen session. Creating a new screen window the alias works as expected.

michalzuber
  • 5,079
  • 2
  • 28
  • 29
  • 1
    This answer isn't useful without explaining how you were using `screen` in the first place, and such an explanation isn't likely to be useful to anyone else. I would just delete the question. – chepner May 31 '17 at 22:50