Hacker News new | ask | show | jobs
by Cthulhu_ 2978 days ago
I'm neither a sh nor powershell guru, but, it kinda feels like that Powershell was intended more as a scripting language, less as a commandline language. sh / bash / etc commands are more terse, but harder to read if they're composed into a shell script.

I mean I still can't wrap my head around [ being a command / executable usable in conditions.

2 comments

The terseness of Bash etc. is a tradeoff. "cat" is short for "concatenate." It's common use to list a single file is more the exploitation of an ambiguous API than a feature...concatenation of one file is like the sound of one hand clapping. I mean "to display the contents of a file use 'cat filename'" is an example of how *nix terseness makes understanding dependent on oral tradition rather than clear written communication. Even the man page doesn't describe using cat to display the contents of a single file [1]. It is only implied via the stdin example once a person understands the abstract relationship between the terminal and files.

[1]: https://linux.die.net/man/1/cat

Since shell languages invariably end up becoming scripting languages (see: Bourne shell and resulting nightmare), Powershell targets being a good tool for both purposes.

When scripting and writing documentation, full commandlet names are encouraged:

  Get-ChildItem | Where-Object { $_.Name.Contains("evidence") } | Remove-Item
When using the command line, there are built-in shortcuts (and users may define their own aliases):

  gci | ?{ $_.name.contains("evidence") } | ri
For the convenience of those hopelessly entrenched in Bourne shell, there are some default aliases:

  ls | ?{ $_.name.contains("evidence") } | rm
Since shell languages invariably end up becoming scripting languages

We need to start paying attention to this phenomenon.