I have about 10 php.ini files on my system, located all over the place, and I wanted to quickly browse through them. I tried this command:locate php.ini | xargs viBut vi warns me Input is not from a terminal and then the console starts getting really weird - after which I need to press :q! to quit vi and then disconnect from the ssh session and reconnect to have the console behave normally again.I think that I sort of understand what's happening here - basically the command hasn't finished when vi started so the command maybe hasn't finished and vi doesn't think that the terminal is in normal mode.I have no idea how to fix it. I have searched Google and also unix.stackexchange.com with poor luck.
xargs and vi - Input is not from a terminal
command line;terminal;vi;xargs
I hate xargs, I really wish it'd just die :-)vi $(locate php.ini)Note: this will have issues if your file paths have spaces, but it is functionally equivalent to your command.This next version will properly handle spaces but is a bit more complicated (newlines in file names will still break it though)(IFS=$'\n'; vi $(locate php.ini))Explanation:What's happening is that programs inherit their file descriptors from the process that spawned them. xargs has its STDIN connected to the STDOUT of locate, so vi has no clue what the original STDIN really in.