0

I have a Windows batch script (to be honest, it's a Groovy script). In this script I determine the root directory of a Cygwin installation. The next step is to find out the current user and home directory. In Cygwin this would be just a

echo $HOME
#=> /home/Christian

What comes pretty close to my problem is the following question: Get results of command from Cygwin in Batch. I would like to execute something like this:

"C:\cygwin[64]\bin\bash[64].exe" "echo $HOME"

However I receive a

#=> /usr/bin/bash[64]: echo $HOME: No such file or directory

This is because bash is expecting a script file and I want to execute a single command. How can this be done? Is there a possibility without putting the command in a script file?

My goal is to get the Windows path to the current users home directory so that I can iterate over this directory from a Windows script.

1 Answer 1

0

The correct option to issue a single command is -c, and before you need to perform a login with --login.

C:\>c:\cygwin64\bin\bash.exe --login -c "cygpath -w $HOME"
#=> C:\cygwin64\home\Christian

I found the answer here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.