2

I've made a bash script that automates a git commit to a remote. However, when it gets to the commit it doesn't pass the SSH key password prompt to the user, it just exits.

Here's the relevant part of the script!

set -e

[...]

read -p "Would you like to upload your app now? [y/n]: " -n 1 -r
echo    # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    exit 1
fi

git add *
git commit -m "Commit (Automated)"
git push cloud master

Not really a shell script person, so any help would be much appreciated!

EDIT: to clarify I want the user to be prompted to enter their password at "git push..."

6
  • 1
    What errors are you getting exactly? I tested your code and it looks to be working fine. Commented Oct 8, 2020 at 17:17
  • Hello! I've got a local password on my SSH key and it's not prompting for that...just wondering if there's something I'm missing re sending the output (e.g. the password prompt) to the console :) Commented Oct 8, 2020 at 17:22
  • hi and welcome to SO! Well, I don't think your missing something. As I said, I just tested it. Anyways, you can try to add a ssh-agent to your currently running terminal and see if it will push then. Commented Oct 8, 2020 at 17:24
  • Thank you! Ok, I'll give that a go :D Commented Oct 8, 2020 at 17:26
  • 1
    Yay, worked it out! Looks like the "set -e" at the top of the script was seeing my git commit's "Everything is up to date" response as a failure and was exiting before the push :) Thanks for your help @mnestorov! Commented Oct 8, 2020 at 17:39

1 Answer 1

2

Solved! Looks like the "set -e" at the top of my script was the culprit. It saw the git commit commands "Everything is up-to-date" response as a command failure and exited. Removing it solved the issue :D

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.