Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Oh, and just another observation about this point right here:

> Bash does not have named parameters for its functions, let alone metadata on them…

Come to think of it, actually a bash function can indeed have named parameters. Because that's exactly what command line flags with values are :-)

    # these invocations are equivalent
    awesome_util --source www.example.com --ignore-headers --dest file
    awesome_util --dest file --source www.example.com --ignore-headers
    awesome_util --ignore-headers --dest file --source www.example.com
In this example, it doesn't matter in what order I put the values for source, dest or the boolean to ignore headers, as they are all named by the associated command line flag.


Yes, but you are referring to standalone scripts, not functions defined within a Bash script.

Compare for example the following helper code used for git command completion inside Bash and inside PowerShell.

Bash: https://github.com/git/git/blob/master/contrib/completion/gi... PowerShell: https://github.com/dahlbyk/posh-git/blob/master/src/GitPromp...

I believe this is clean Bash code and clean PowerShell code, and a script with a certain complexity. The functions inside the Bash script are documented using comments, the ones inside the PowerShell script are documented using "structured comments" (similar to javadoc/xmldoc/...). The parameters of the functions inside the PowerShell script also contain metadata which is used to provide completion on the commandline and similar functionality as the command line flags you demonstrated.

I just learned about 'getopts' in Bash, which you can actually also use to implement parameters to a Bash function. So what you are showing on a script level, can also be applied for functions. Did not know about that.

Still, not saying PowerShell is better than Bash in a Linux context, but it seems a lot of Linux users have a gut reaction to right out reject PowerShell. I think it does have some advantages for certain use cases, like more complex scripts, a cross-platform context, ... and of course, for someone with a .NET background it's easier to program more complex things with it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: