How do I prevent terminal from closing out out after git hook is called from bash script?Get the source directory of a Bash script from within the script itselfHow to remove local (untracked) files from the current Git working treeHow to iterate over arguments in a Bash scriptHow to selectively merge or pick changes from another branch in Git?How to check if a program exists from a Bash script?Pipe to/from the clipboard in Bash scriptHow do I check out a remote Git branch?How can I delete a file from a Git repository?How to replace master branch in Git, entirely, from another branch?How can I determine the URL that a local Git repository was originally cloned from?
Why do many websites hide input when entering a OTP
Driving test in New Zealand?
Sci-fi story about aliens with cells based on arsenic or nitrogen, poisoned by oxygen
Notation clarity question for a conglomerate of accidentals
Can I return my ability to cast Wish by using the Glyph of Warding spell?
Generating Roman numerals with dice
Non-electric Laser
How to "Start as close to the end as possible", and why to do so?
What does "それに意味を持たせるか" mean?
Why is the time of useful consciousness only seconds at high altitudes, when I can hold my breath much longer at ground level?
What makes a character irredeemable?
What’s the BrE for “shotgun wedding”?
Did the Humans find out about Gaius Baltar's role in the sabotage of the fleet?
Would houseruling two or more instances of resistance to the same element as immunity be overly unbalanced?
Determine the Winner of a Game of Australian Football
Why is my vegetable stock bitter, but the chicken stock not?
In what sense is SL(2,q) "very far from abelian"?
Was there an autocomplete utility in MS-DOS?
What benefits are there to blocking most search engines?
Has Boris Johnson ever referred to any of his opponents as "traitors"?
"cd" into /sys/kernel/debug/tracing causes permission change
What is the origin of the minced oath “Jiminy”?
How to tension rope between two trees?
Is there any problem with students seeing faculty naked in university gym?
How do I prevent terminal from closing out out after git hook is called from bash script?
Get the source directory of a Bash script from within the script itselfHow to remove local (untracked) files from the current Git working treeHow to iterate over arguments in a Bash scriptHow to selectively merge or pick changes from another branch in Git?How to check if a program exists from a Bash script?Pipe to/from the clipboard in Bash scriptHow do I check out a remote Git branch?How can I delete a file from a Git repository?How to replace master branch in Git, entirely, from another branch?How can I determine the URL that a local Git repository was originally cloned from?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I'm curious to learn and know why a terminal is crashing out. I have a bash function, gc_push_wh
, that calls a git hook like so:
git_push_wh ()
GIT_DIR_="$(git rev-parse --git-dir)"
BRANCH="$(git rev-parse --symbolic --abbrev-ref $(git symbolic-ref HEAD))"
git push "$@"
POST_PUSH="$GIT_DIR_/../hooks/post-push"
test $? -eq 0 && test -x "$POST_PUSH" &&
exec "$POST_PUSH" "$BRANCH" "$@"
All this works fine. But when the hook terminates, the terminal closes out. Here is what's in the hook:
#!/usr/bin/env bash
ssh -t root@10.0.0.222 -p 30000 "cd ~/.dotfiles; git pull; lb;"
I have a git alias set up to run with this function like so:
git gcpush
When run with the git alias, the terminal does not close out.
IMPORTANT: I tried throwing a read command at the end of the hook but after I hit enter, the terminal still closes out.
bash git
add a comment
|
I'm curious to learn and know why a terminal is crashing out. I have a bash function, gc_push_wh
, that calls a git hook like so:
git_push_wh ()
GIT_DIR_="$(git rev-parse --git-dir)"
BRANCH="$(git rev-parse --symbolic --abbrev-ref $(git symbolic-ref HEAD))"
git push "$@"
POST_PUSH="$GIT_DIR_/../hooks/post-push"
test $? -eq 0 && test -x "$POST_PUSH" &&
exec "$POST_PUSH" "$BRANCH" "$@"
All this works fine. But when the hook terminates, the terminal closes out. Here is what's in the hook:
#!/usr/bin/env bash
ssh -t root@10.0.0.222 -p 30000 "cd ~/.dotfiles; git pull; lb;"
I have a git alias set up to run with this function like so:
git gcpush
When run with the git alias, the terminal does not close out.
IMPORTANT: I tried throwing a read command at the end of the hook but after I hit enter, the terminal still closes out.
bash git
add a comment
|
I'm curious to learn and know why a terminal is crashing out. I have a bash function, gc_push_wh
, that calls a git hook like so:
git_push_wh ()
GIT_DIR_="$(git rev-parse --git-dir)"
BRANCH="$(git rev-parse --symbolic --abbrev-ref $(git symbolic-ref HEAD))"
git push "$@"
POST_PUSH="$GIT_DIR_/../hooks/post-push"
test $? -eq 0 && test -x "$POST_PUSH" &&
exec "$POST_PUSH" "$BRANCH" "$@"
All this works fine. But when the hook terminates, the terminal closes out. Here is what's in the hook:
#!/usr/bin/env bash
ssh -t root@10.0.0.222 -p 30000 "cd ~/.dotfiles; git pull; lb;"
I have a git alias set up to run with this function like so:
git gcpush
When run with the git alias, the terminal does not close out.
IMPORTANT: I tried throwing a read command at the end of the hook but after I hit enter, the terminal still closes out.
bash git
I'm curious to learn and know why a terminal is crashing out. I have a bash function, gc_push_wh
, that calls a git hook like so:
git_push_wh ()
GIT_DIR_="$(git rev-parse --git-dir)"
BRANCH="$(git rev-parse --symbolic --abbrev-ref $(git symbolic-ref HEAD))"
git push "$@"
POST_PUSH="$GIT_DIR_/../hooks/post-push"
test $? -eq 0 && test -x "$POST_PUSH" &&
exec "$POST_PUSH" "$BRANCH" "$@"
All this works fine. But when the hook terminates, the terminal closes out. Here is what's in the hook:
#!/usr/bin/env bash
ssh -t root@10.0.0.222 -p 30000 "cd ~/.dotfiles; git pull; lb;"
I have a git alias set up to run with this function like so:
git gcpush
When run with the git alias, the terminal does not close out.
IMPORTANT: I tried throwing a read command at the end of the hook but after I hit enter, the terminal still closes out.
bash git
bash git
asked Mar 28 at 21:11
StevieDStevieD
1,1039 silver badges20 bronze badges
1,1039 silver badges20 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
The exec
command is replacing the currently running bash process's image with the image of a new bash process that will run the script in $POST_PUSH
. Hence, the process will finish running when that script exits. It will never never come back to the bash process that you started with, as would have happened had the script been run in a subshell.
If you replace, the line
exec "$POST_PUSH" "$BRANCH" "$@"
with
"$POST_PUSH" "$BRANCH" "$@"
you will achieve what you wish to.
1
I just spotted this a few seconds ago myself. copy/paste programming is a huge time killer. Thanks!
– StevieD
Mar 28 at 21:27
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406899%2fhow-do-i-prevent-terminal-from-closing-out-out-after-git-hook-is-called-from-bas%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The exec
command is replacing the currently running bash process's image with the image of a new bash process that will run the script in $POST_PUSH
. Hence, the process will finish running when that script exits. It will never never come back to the bash process that you started with, as would have happened had the script been run in a subshell.
If you replace, the line
exec "$POST_PUSH" "$BRANCH" "$@"
with
"$POST_PUSH" "$BRANCH" "$@"
you will achieve what you wish to.
1
I just spotted this a few seconds ago myself. copy/paste programming is a huge time killer. Thanks!
– StevieD
Mar 28 at 21:27
add a comment
|
The exec
command is replacing the currently running bash process's image with the image of a new bash process that will run the script in $POST_PUSH
. Hence, the process will finish running when that script exits. It will never never come back to the bash process that you started with, as would have happened had the script been run in a subshell.
If you replace, the line
exec "$POST_PUSH" "$BRANCH" "$@"
with
"$POST_PUSH" "$BRANCH" "$@"
you will achieve what you wish to.
1
I just spotted this a few seconds ago myself. copy/paste programming is a huge time killer. Thanks!
– StevieD
Mar 28 at 21:27
add a comment
|
The exec
command is replacing the currently running bash process's image with the image of a new bash process that will run the script in $POST_PUSH
. Hence, the process will finish running when that script exits. It will never never come back to the bash process that you started with, as would have happened had the script been run in a subshell.
If you replace, the line
exec "$POST_PUSH" "$BRANCH" "$@"
with
"$POST_PUSH" "$BRANCH" "$@"
you will achieve what you wish to.
The exec
command is replacing the currently running bash process's image with the image of a new bash process that will run the script in $POST_PUSH
. Hence, the process will finish running when that script exits. It will never never come back to the bash process that you started with, as would have happened had the script been run in a subshell.
If you replace, the line
exec "$POST_PUSH" "$BRANCH" "$@"
with
"$POST_PUSH" "$BRANCH" "$@"
you will achieve what you wish to.
answered Mar 28 at 21:23
euphoria83euphoria83
7,44616 gold badges53 silver badges67 bronze badges
7,44616 gold badges53 silver badges67 bronze badges
1
I just spotted this a few seconds ago myself. copy/paste programming is a huge time killer. Thanks!
– StevieD
Mar 28 at 21:27
add a comment
|
1
I just spotted this a few seconds ago myself. copy/paste programming is a huge time killer. Thanks!
– StevieD
Mar 28 at 21:27
1
1
I just spotted this a few seconds ago myself. copy/paste programming is a huge time killer. Thanks!
– StevieD
Mar 28 at 21:27
I just spotted this a few seconds ago myself. copy/paste programming is a huge time killer. Thanks!
– StevieD
Mar 28 at 21:27
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406899%2fhow-do-i-prevent-terminal-from-closing-out-out-after-git-hook-is-called-from-bas%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown