Live data from Hacker News

PowerShell is open sourced and is available on Linux

azure.microsoft.com

681–690 of 790 posts

Re: PowerShell is open sourced and is available on Linux

#681
post #644

Earlier quoted context omitted.

> Normal shell usage means doing a lot of one-shot pipelines incrementally. Sure because no-one ever takes those "one-shot" pipelines full of `cut`s and `grep`s and distributes them in real products. /s As far as I can tell, Powershell is designed for scripts that are meant to be distributed , so they must be robust. Normal 'text scraping' Bash is shit at that.

If we are not talking about interactive use then to distribute "robust" scripts, you could use nicer and richer Perl, Python eco-systems. For interactive use, the conciseness, the human-readability of input/output and the fault-tolerance to unrelated changes in the input/output formats provided by Unix shells are also preferable.

The motivation for PowerShell was to have something good at both. Why switch contexts when moving from interactive use to coded automation if you don't have to?

Re: PowerShell is open sourced and is available on Linux

#682

Earlier quoted context omitted.

getting an IP is still pretty ugly, somehow: ip address show dev eno1|grep 'inet '|cut '-d ' -f6 But I wouldn't call it unreliable. The cut is the only really nasty bit. Changing your fstab is easy with a little awk: $2=="/tmp"{$4=$4 ",nosuid"} {print $0} Given, it won't remove contradicting options...

It's unreliable, because you don't know where you'll find 'inet ' or what's the specific spacing of the output. Also, that's not the ip, because you've still got the cidr attached. And no, fstab is not easy either. For example it fails for: # /tmp has option_blah in order to ... changing it to: # /tmp has option_blah,nosuid in order to ... Confusing the next person to look at the well intended comment. It's no imposs…

>PS. also slightly annoying is that everyone is so concerned about the text processing part that barely anyone checks what the tool itself can do. (ip -4 -o a s dev eno1 | awk '{print $4}')

Actually, I spend a while digging through the manpage to try and find this. ip has awful docs.

As for the comment problem, yeah, not optimal.

Re: PowerShell is open sourced and is available on Linux

#683

Earlier quoted context omitted.

So then you switch back to another shell?

Yes, or you buy Windows. That's the purpose of EEE. That's similar to saying, use a different word processor. Just in this case Powershell is less used than Microsoft Word.

The purpose of EEE is to extinguish a technology. Your situation doesn't hold up because PowerShell is MIT licensed. Even is Microsoft did release a new version that was Windows only (which, given their use case, makes no sense), there's nothing stopping the community from forking the repo and adding those features, or porting those features to another technology.

People will continue to trumpet the sound EEE banner every time Microsoft does something that people like. The problem is that waging an EEE campaign with MIT licensed technologies on Github is extremely ineffective. Also, it's pretty clear that while Windows is still a big part of Microsoft, they are trying to move beyond the desktop. The rise of macOS, the proliferation of mobile devices with iOS and Android, all these developments have caused the company to shift its strategy to the cloud, namely Azure. Even in that space, they can't wage an EEE campaign, because with competitors like Amazon and Google, there's no way they can lock you into Azure

Times have changed, and so has the company's strategy. Whether or not the company's culture has changed is not something I am concerned with. They have enough watchers that call them out, like with the Windows 10 update debacle and the collection of telemetry data. I am more interested in their actions with regards to their technology, because it's my opinion that have some of the best people working on languages and tools.

Re: PowerShell is open sourced and is available on Linux

#684

Earlier quoted context omitted.

No, actually it's quite apt. PowerShell, or at least the concept behind PowerShel, is an improvement/superset over the Unix shells -- and can do whatever the shells can do, plus stuff they cannot do, because they don't support typed entities. Its problems are not technical or conceptual -- they are ecosystem and historical: lack of compatible tools, windows-only, etc.

Or to the point of the original parent: the industry considers powershell a solution in search of a problem.

Only those that disregard the inventions from Xerox and ETHZ.

Powershell ideas go back to how REPLs work in those environments.

Re: PowerShell is open sourced and is available on Linux

#685

Earlier quoted context omitted.

...Which is why I said it was ugly. The grep probably won't break, the cut is more likely to. This is in part because the 'ip' command isn't very well designed. A better solution I found is ip addr show wlan0 | grep -Po 'inet \K[\d.]+' Which is less likely to break. If your system supports it, hostname -I Works great. However, this seems to be an ubuntuism, and it doesn't work on my system.

ip addr show eth0 | awk '/inet/ { print $2 }' Will be better ;) 'inet[::space::] ' not working with ipv6 addresses.

I though there was a specific desire for ipv4 addrs. That's why the space was there.

Re: PowerShell is open sourced and is available on Linux

#686
post #413

Earlier quoted context omitted.

It wasn't cmd that was the problem (although, it is weak); it was how Windows exposed APIs to allow automated solutions. You had two options: VBScript (which is a glorified COM+ agent) or a "real" programming language like VB6/C# which mixed COM+ with Win32 API calls (which are too hard to use for most non-programmers). Powershell within itself does improve CMD. But that isn't primarily how PS pushed Windows automati…

If all this API effort had gone into a real cross-platform language (Python, Ruby, or even Perl which was king in 2001), Windows would have flourished. They went for their traditional lock-in approach instead, so now they have to catch up.

Windows did flourish...

And are you suggesting that Perl would have been a better solution for a Windows interactive shell and automation tool?

Are you going for the more readable argument? Or the more strongly typed argument?

Re: PowerShell is open sourced and is available on Linux

#687
post #616

Earlier quoted context omitted.

But that's picking an example where a. You can still use the native binary just as well. Especially in this case. b. There was no PowerShell cmdlet for it at the time. There also isn't one for executing Python code, you still have to call python. Or, if you're so inclined, load up IronPython's assembly, and use an overly verbose .NET method call ... c. There now is a cmdlet for doing so: Expand-ZipFile. I'm actually…

If you're used to cmd or bash, the jump in verbosity is very noticeable and definitely gets in the way. It might be a cultural thing, because I'm no fan of C# and its typical style either; no surprise then, that I find PS syntax exceedingly verbose too. It just feels excessively bureaucratic and awkward to have to write so much. On the other hand, bash, awk, sed, and all the typical Unix commands and its associated e…

> Why is it "Expand-ZipFile", and not "ZipFile-Expand", "Expand-Zip-Format-Archive", or something else? In contrast, "unzip" is short and easy to remember.

Iff you know it already. PowerShell is built around a few conventions. One is that all commands share the Verb-Noun pattern. The verb always comes first. Then there are a bunch of common verbs that all share the same basic meaning, regardless of context. Expand is such a verb that is the opposite of the Compress verb. You may not like then choice of verb but there are always going to be names you didn't choose, so that's probably a petty point. In the end, PowerShell makes it easy to discover commands you may vaguely know exist. I'd argue that also helps remembering them once you know them. Just from knowing unzip you wouldn't be able to guess the command to extract a GZIP file, for example.

___________

P.S.: I have to retract part of my original post here. Expand-ZipFile does not exist natively in PowerShell. I stumbled across http://ss64.com/ps/zip.html and while that site does have documentation for all built-in cmdlets, I didn't read too closely and this was actually documentation for a wrapper around the .NET framework's own functionality. This does not change the discussion about the name and discoverability, though, except that New-ZipFile should probably use a different verb. Actually, the PowerShell cmdlets for handling ZIP files are Compress-Archive and Expand-Archive, exhibiting the properly mirrored verbs.

Re: PowerShell is open sourced and is available on Linux

#688

Earlier quoted context omitted.

For one, sane dependency management that doesn't require vendoring.

You can reference projects or other files that are in submodules. What about the .NET build process makes vendoring the only option? Even so, it's always been more convenient in my experience when something just ships with fixed versions of dependencies already inside it. Those versions are known to work with the codebase and there's no chance of new bugs or other incompatible behavior being introduced from updates t…

> What about the .NET build process makes vendoring the only option?

AFAIK, even NuGet doesn't allow you to just check in the dependency spec, rather than the contents of all of your dependencies.

> Even so, it's always been more convenient in my experience when something just ships with fixed versions of dependencies already inside it.

I agree. But that doesn't mean that they belong in Git, nor that they should even be copied to every single project.

Re: PowerShell is open sourced and is available on Linux

#690
post #17

Earlier quoted context omitted.

As a full-time Linux user, I have to say that bash is overrated. For instance, on Windows I could press the up arrow through my history 20x to find a group of commands I want to run, press Enter, then press DOWN for the following command, then enter, then DOWN until I run them all. In Bash, I need to press UP 20x every single time. Yes, you can customize it a lot, and you can script it but default bash isn't that spe…

If you put this in your `~/.inputrc` [1]: "\e[A": history-search-backward "\e[B": history-search-forward "\e[C": forward-char "\e[D": backward-char you can start typing a previous command and go up through your history for all commands starting with whatever you currently have typed into the bash shell. Reset the scrolling through the history with `ctrl+c`. Personally, I hate that powershell remembers your position i…

The search by previous characters seems to be the default behaviour of FreeBSD's t/csh. Confused the hell out of me at first because Ctrl+R isn't reverse search.
Post reply on HN