1

1. Summary

I don't find, how I can use command output as variable, use cross-platform syntax.


2. Example

For example, I want get URL of my remote git repository:

SashaChernykh@DESKTOP-EEOT0TN /cygdrive/d/SashaBranchReleaseIt
$ git ls-remote --get-url
https://github.com/Kristinita/SashaBranchReleaseIt.git

I run command in Linux/Cygwin:

SashaChernykh@DESKTOP-EEOT0TN /cygdrive/d/SashaBranchReleaseIt
$ echo "URL is `git ls-remote --get-url`"
URL is https://github.com/Kristinita/SashaBranchReleaseIt.git

I run the same command in Windows cmd.exe.

D:\SashaBranchReleaseIt>echo "URL is `git ls-remote --get-url`"
URL is `git ls-remote --get-url`

or

D:\SashaBranchReleaseIt>echo "URL is $(git ls-remote --get-url)"
URL is $(git ls-remote --get-url)

doesn't work.

I don't find syntax, that will be compatible with Windows and UNIX both.


3. Conditions

3.1. Not expected

I'm looking for a solution, that would be possible run command in default Windows cmd.exe. Windows user is not obliged to establish Cygwin, Bash for Windows or another terminal.

3.2. Expected

Windows user can add in Path environment variable path to Cygwin, GnuWin32 CoreUtils commands or path for any UNIX tools, that ported to Windows.


4. Not helped

  1. I don't find, how I can solve my problem in answers for this question.

5. Do not offer

  1. Yes, I know, that in Windows I can get similar behavior (example), but them Windows-specific. I'm looking for cross-platform command, not Windows-specific.

0 Answers0