Bash Script Help "if (user input) = then (var) =" -
i writing script cherry pick open changes gerrit. found 1 works sort of, though need able change inputs not have script each repo hardcoded specific repo's information.
#! /bin/sh remote="${1-review}" ssh -p 29418 user@gerrit.remote.com gerrit query --format=text --patch-sets status:open branch:xxx project:xxx | grep revision: | awk '{print $2;}' | while read id git fetch "${remote}" && git cherry-pick "${id}" done
now have been able pick open changes trying make can pass input change username, branch, project , remote. current method need enter username, project, branch, , remote manually script. specific repo.
i have been having trouble if
/then
statements. know looks none of things asking coded, wanted provide working model though.
i did change username , particular details, easy enough use script cherry-pick inserting requisite information.
if this:
project="$1" if [ "$1" = "xx" ]; "$project="project:name of project"
then bash returns xx command not found
. not trying make command want input inserted ssh command later on. trying not use if
else if
project
can whatever input.
i think there though stumped @ point.
assume $1 equal "xx". code:
project="$1"
will assign project=xx. next,
if [ "$1" = "xx" ];
is true, "then" clause executed. clause is:
"$project="project:name of project"
that tries execute command "xx=...", causing "command not found"
suggestion, remove $ on line, in:
project="project:name of project"
Comments
Post a Comment