0

I'm running this line on my shell script

sudo npm install -g yaml-cli -y 2>&1 >/dev/null

I would expect to get no output, but I still get

npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
user3142695
  • 1,529
  • 7
  • 20
  • 34

1 Answers1

0

Redirections are evaluated from left to right, you have got this other way around. Just swap the redirections:

sudo npm install -g yaml-cli -y >/dev/null 2>&1

In sudo npm install -g yaml-cli -y 2>&1 >/dev/null:

  • First, for 2>&1, the STDERR (FD 2) is being sent to the terminal (precisely, where the STDOUT (FD 1) is currently attached to, presumably terminal), so the errors are being shown

  • Then, for >/dev/null, the STDOUT is being sent to /dev/null, this happens later

heemayl
  • 54,820
  • 8
  • 124
  • 141