Earlier quoted context omitted.
I agree, especially for the behaviour from the parent: "ps -f" truncates long lines instead of wrapping, while "ps -f | cat" lets the long lines live How people usually discover what these commands do is by running them interactively, and if that results in some output being hidden vs being run noninteractively, then they have little reason to believe that it could yield more output than what they're used to seeing.…
On a quick look through ps's manpage I couldn't find anything about this. Am I missing something?
Hints for writing Unix tools
111–120 of 131 posts
Re: Hints for writing Unix tools
#112Earlier quoted context omitted.
I have never used a computer that had access to Powershell, but in my new job I may have to do some small stuff to tie some systems together. I'm terrified of learning it because I don't want to be lured into some kind of lock-in scenario.
Well, you can only use it on Windows. But I mean come on, "terrified?" Bash scripts are not too useful in Windows either.
Re: Hints for writing Unix tools
#113Earlier quoted context omitted.
I think it depends what sort of things you use it for. I often use it to switch on or off ANSI colourization, which doesn't really violate the principle of least surprise. When used sparingly and thoughtfully, I've never personally had an issue with it.
You may not have issue with the sort of things you use it for, but others might. For example, I run shells in Emacs and have had to tweak loads of shell scripts written by colleagues to fix their poorly-implemented colourisation. It's useful to know when a test has failed; it's not so useful to have the whole terminal set to white text on a pale pink background. One day I couldn't SSH into our servers from Emacs. It…
Re: Hints for writing Unix tools
#114Earlier quoted context omitted.
Well, if it's part of your job I'd say it's not a decision at all...
If you can't accomplish the same goals in a portable way. Of course, if you can put the knowledge to work as soon as you learn it, you're already starting to recoup your investment.
Re: Hints for writing Unix tools
#115Earlier quoted context omitted.
Well, you can only use it on Windows. But I mean come on, "terrified?" Bash scripts are not too useful in Windows either.
cygwin does it's job well.
Re: Hints for writing Unix tools
#116Earlier quoted context omitted.
> That breaks when you have newlines in filenames, no? That seems like an extremely pathological case.
Pathological or not, ensuring that pathnames can essentially contain any byte value except the 0 terminator, and it will still work, is important to prevent surprising behaviour which often has security implications.
Edit: my mistake, they can't contain nulls either: https://news.ycombinator.com/item?id=8485861
Re: Hints for writing Unix tools
#117Earlier quoted context omitted.
IMO, this is an anti-pattern. It's violates the principle of least surprise. (How come I see X when I run the command, but I can't grep for X in its output? How come it works when I run it from my interactive shell, but it's broken when I run it from a script? And things like that.)
Indeed, the GNU Coding Standards explicitly argues against doing that: “ please don’t make the behavior of a command-line program depend on the type of output device it gets as standard output or standard input. ”¹ ① https://www.gnu.org/prep/standards/standards.html#User-Inter...
Re: Hints for writing Unix tools
#118Earlier quoted context omitted.
IMO, this is an anti-pattern. It's violates the principle of least surprise. (How come I see X when I run the command, but I can't grep for X in its output? How come it works when I run it from my interactive shell, but it's broken when I run it from a script? And things like that.)
And yet .. programs are not just for composition. They have to behave sensibly for people. I love that 'git log' outputs in a pager. 'svn log' by comparison is nuts.
Some work has been done on the svn side: http://svn.apache.org/repos/asf/subversion/branches/automati...
However, it's not on trunk yet because it's hard to find good defaults. An automatic pager makes sense for some commands, but not all -- and in a meritocratic development model this kind of thing can cause an endless discussion... I suspect we'll eventually merge the feature in a disabled by default state and allow users to enable it on a per-command basis.
Git's hard-coding of options passed to the pager has problems, too: https://mail-archives.apache.org/mod_mbox/subversion-dev/201...
Re: Hints for writing Unix tools
#119I have a strong bias against people who quote their own tweets in their own blog posts. I find this to be highly narcissistic.
Re: Hints for writing Unix tools
#120Earlier quoted context omitted.
Indeed, the GNU Coding Standards explicitly argues against doing that: “ please don’t make the behavior of a command-line program depend on the type of output device it gets as standard output or standard input. ”¹ ① https://www.gnu.org/prep/standards/standards.html#User-Inter...
Interesting. Doesn't git (a pretty new tool) violate this? I think running log from the terminal pauses per page of output but if you pipe it to something it pipes all the content.
That said, I'm not entirely sure which git pipes to.