r/linuxmasterrace • u/kiler129 Glorious Debian • Aug 06 '21
Meme BASH is the worst - PowerShell FTW!
45
u/paderich Aug 06 '21
Disgusting 🤮
17
u/kiler129 Glorious Debian Aug 06 '21
Wait, are you saying it's not as beautiful as XML? /s
11
Aug 06 '21
Actually you can't beat a nice bit o' JSON...
18
u/kiler129 Glorious Debian Aug 06 '21
I love JSON until I need to:
add comments
read key=>value maps in order (albeit most tools handle that now even if "out of spec")
1
u/zpangwin Reddit is partly owned by China/Tencent. r/RedditAlternatives Aug 08 '21
still better than yaml. i fucking hate it when languages try to police my whitespace (markup, scripting, or otherwise)
1
u/kiler129 Glorious Debian Aug 08 '21
Still better thank makefile…. But jokes aside YAML with an IDE is great, but without it it is utterly miserable.
I get why JSON originally didn’t add comments or kept order of objects. But why don’t we have JSONv2 with these things when clearly it became way more than a data storage format?!
1
Oct 03 '21
Does it want to be more? A tool designed for a specific task and people using it for everything else too, always leads to the demise of the tool long-term (it's become bloated and slow, has unclear specification (HTML), etc.).
9
u/4hpp1273 Glorious Arch Aug 06 '21
The bash version can be even shorter (>>f or >f if you want to trash the file)
3
u/kiler129 Glorious Debian Aug 06 '21
My favorite so far is still
cat >ffor pasting files instead of what people usually do (nano f=> paste => Ctrl+X => Y)9
u/4hpp1273 Glorious Arch Aug 06 '21
Is that another case of cat abuse? The proper way to paste to file is
xclip -o>f8
u/kiler129 Glorious Debian Aug 06 '21
I like abusing cat but not cats ;]
xclip is great but in my day-to-day usage of Linux I mostly deal with a serial connection (or at best SSH).
5
u/gosand Aug 06 '21
xclip -o>f
~ $ xclip -o>f bash: xclip: command not found ~ $3
u/Ruashiba Aug 06 '21
If I recall correctly(I'm on the phone atm) this is a x11 utility. More specifically the clipboard, hence the name. If you are on Wayland(or just pure tty), you most likely won't have this utility.
3
3
u/gosand Aug 07 '21
Which was precisely my point. Why bring it up when the post is about bash and is tied to X.
20
u/nuttertools Aug 06 '21
People conflating coreutils with bash...checks sub....double checks sub....uhhh wow.
11
u/kiler129 Glorious Debian Aug 06 '21
To be fair
touchis a built-in in some shells (e.g.busybox). If we're on the pure bash train with commands we can doecho -n >>f4
u/nuttertools Aug 06 '21
busybox/tree/coreutils/touch.c, I totally knew that and didn't just learn something new via a Google. I like the echo line more...but...coreutils still.
9
u/kiler129 Glorious Debian Aug 06 '21
To be fair most of the people who don’t deal with like buildroot environments or embedded don’t know about BB intricacies ;)
Coreutils thou are available pretty much everywhere so I will consider them in the same way as tools built into P.S. environment (as this isn’t just one flat binary either).
1
u/nuttertools Aug 06 '21
I can see that from PS2.0 and up, take enough steps back and it looks rather similar.
6
u/fuj1n Aug 07 '21 edited Aug 07 '21
The thing is, you can do that in PowerShell with
echo (backtick)n >file.txtwhich has a very similar footprint, or in CMD, it'd beecho. >file.txtwhich is slightly more compact.There are lots of things to criticize PowerShell for (i.e. its verbosity), and to praise bash for, but this ain't it chief.
Edit: fixed formatting, reddit really didn't like that backtick in `n, so I replaced it with (backtick)
37
u/sjveivdn arch&debian Aug 06 '21
Typing Backslashes is horrible horrible.
9
u/fzwjf70850 Aug 07 '21 edited Aug 07 '21
You know what’s worse? Escaping bloody characters with ‘^’ that is just eww. Windows is not a terminal operating system unfortunately
2
u/luciouscortana Glorious Fedora Aug 07 '21
I also don't like having spaces in directory names, it cuts the path which I'd have to use quote.
17
11
4
7
u/avalenci Aug 06 '21 edited Aug 07 '21
IMHO, you dont compare a PowerShell script with a bash one. You would compare it with a Python script
2
u/Reihar Glorious Arch Aug 07 '21
That's even more unfair to PowerShell!
2
u/avalenci Aug 07 '21
In the sense that in both python and powershell you deal with objects. In bash you deal with strings.
4
2
5
u/rick_D_K Glorious Void Linux Aug 06 '21
As a Windows sysadmin I have powershell installed on my arch pc, Debian server and void laptop.
15
1
1
1
Aug 07 '21
~/ is useless in this case. It will always place it in the directory you are currently in without the ~/
If you want to place it somewhere else then use the ~/./.
1
1
1
0
Aug 06 '21
[deleted]
2
u/dthusian Glorious Alpine Aug 06 '21
Powershell can interact with COM, which means if you wanted to you could write a DirectX 12 game in Powershell
12
1
u/Ruashiba Aug 06 '21
I like it just by the fact that it's incredibly handy for azure/sharepoint/m365 sort of deals, it's much easier to create a script to create/deploy xyz than to do it by hand on whatever web interface.
But outside Microsoft realm, more general use, I don't see myself using it.
2
u/kiler129 Glorious Debian Aug 07 '21
Out of curiosity: what advantage does it have over a different CLI util? I'm assuming there are some for that, but I mainly deal with AWS.
4
u/Ruashiba Aug 07 '21
I don't recall any other utility for these ms things, at least not official or highly supported (open source or not) 3rd party. On linux I mind add, surely there's something on windows.
Maybe Ansible for deployment itself? Never tried it though.
1
u/KikeJesus Aug 07 '21
Look into Azure CLI, basically an (official) bash variant of Azure PowerShell
0
280
u/varble A-OK Aug 06 '21 edited Aug 06 '21
Forgot a bit there on powershell; if the file exists, there will be no update on the file at all. You also have to pass -Force
This will override the contents of the file, which touch doesn't do, so -Value (Get-Content) is needed:
Whoopsie! Since Get-Content is an array of lines, you have to join the lines with a newline:
Hold up! The encoding changed from ascii to UTF-8... have to find that out, and research encoding types to add to the list if not present...
Ah hell, New-Item doesn't have an encoding option! Guess we'll switch to piping to Out-File:
Suppressing the error for when there is no file:
There we are, so simple anyone could do it!
Welcome to my life in a Windows shop.