Identify underlying OS in bash on windows [duplicate] - windows

This question already has answers here:
How to check if a program is run in Bash on Ubuntu on Windows and not just plain Ubuntu?
(15 answers)
Closed 5 years ago.
Is there a simple way to determine if bash is running on Windows? Running uname gives "Linux" which is not correct.

I have not personally tested this but if [ -d /mnt/C ] may work.
This is probably a terrible solution

Related

shebang in macos bin/bash incompatible with linux and windows /usr/bin/bash [duplicate]

This question already has answers here:
What is the preferred Bash shebang ("#!")?
(6 answers)
Why is #!/usr/bin/env bash superior to #!/bin/bash?
(8 answers)
Closed 4 months ago.
I have a shell script intended to run as bash, on all of MacOS, Windows and Linux (Ubuntu).
The problem is that the shebang is not compatible between MacOS and the others, as MacOS expects /bin/bash while Windows and Linux expect /usr/bin/bash.
/usr/bin/bash is not available on MacOS, and sudo ln -s /bin/bash /usr/bin/bash fails as well (I guess, OS protected write?).
How do I write a bash shebang that works correctly on all OSs?

Running MATLAB script from terminal Mac [duplicate]

This question already has answers here:
matlab execute script from linux command line
(3 answers)
How to call MATLAB script from command line?
(4 answers)
Closed 1 year ago.
I am trying to run a matlab script from the terminal on MacOS. I am doing the following:
/../matlab -nodisplay -r
to open matlab from terminal, then to run the script that is on a different path I write
cd ('/.../test/')
test1.m
It runs, I get some error regarding the font. But I am not able to visualise the plots in the script, any suggestions?

How to access WSL PATH from Powershell core? [duplicate]

This question already has an answer here:
What is the difference between calling a command via "wsl [command]" and opening a wsl shell and calling "[command]"?
(1 answer)
Closed 1 year ago.
If I open up the Ubuntu app (terminal) and type echo $PATH, I get a bunch of directories. If I type wsl echo $PATH in Powershell core, I get absolutely nothing (a blank row). I would like to run a Linux command from Powershell core, how do I do that?
That's because the .bashrc isn't run when you just run wsl <command>, you need to run wsl bash -c '<command>', or run <command> while inside a bash shell.

mac vscode bash: shopt: globstar: invalid shell option name [duplicate]

This question already has answers here:
Associative arrays: error "declare: -A: invalid option"
(10 answers)
How to get Bash version number in OS X
(3 answers)
Closed 3 years ago.
Running vscode on Mac. I updated the Mac bash version and, as you can see the built-in vscode terminal shows the same version of bash as that of the Mac terminal. When I source my .bash_profile, I get the invalid shell option name error in the vscode terminal. What is causing this?
FWIW - the Terminal > Integrated > Shell: Osx is set to bin/bash, if that is not obvious. And, my SHELL variable is the same.

Bash command on cURL for Windows [duplicate]

This question already has answers here:
How to run .sh on Windows Command Prompt?
(11 answers)
Closed 5 years ago.
I want to install Hyperledger Fabric to build blockchain apps and the documentation tells me to run a bash command to extract platform-specific binaries.
http://hyperledger-fabric.readthedocs.io/en/release/samples.html#binaries
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/v1.0.5/scripts/bootstrap.sh | bash -s 1.0.5
And to this, Terminal outputs:
'bash' is not recognized as an internal or external command, operable program or batch file.
What's the problem I'm facing? I'm running cURL version:
curl 7.58.0 (x86_64-pc-win32) libcurl/7.58.0 OpenSSL/1.1.0g (WinSSL) zlib/1.2.11 WinIDN libssh2/1.8.0 nghttp2/1.30.0
PS: Already installed curl into environment variables.
The command you pasted pipes all its output to a program called bash. This is not a standard program for windows.
As stated on the website you've linked:
If you are running on Windows you will want to make use of the Docker Quickstart Terminal for the upcoming terminal commands. Please visit the Prerequisites if you haven’t previously installed it.
So... use the Quickstart Terminal and read about the Prerequisites first?

Resources