Comments (12)
Maybe redirecting the output into a tempfile, which gets outputted when git exits with an exitcode != 0 ?
from homeshick.
I'm not too fond of using temporary files for that. Maybe homeshick could save the output in a variable using a subshell. I don't think you can check the exit code of a process in a subshell though.
Maybe we can do this instead?
output=$(git clone --quiet $git_repo $repo_path; echo "Exit code was $?")
if [ ${output:${#output}-1} != 0 ]; then
err "Unable to clone $git_repo. Git says:" "$output"
fi
from homeshick.
Just realised this doesn't take of exit codes 10,20,30 etc.
output=$(git clone --quiet $git_repo $repo_path; echo "Exit code was $?")
if [ "${output:${#output}-1}" != " 0" ]; then
err "Unable to clone $git_repo. Git says:" "$output"
fi
from homeshick.
Oh, I see...
output=$(git clone --quiet $git_repo $repo_path; exit $?)
if [ $? != 0 ]; then
err "Unable to clone $git_repo. Git says:" "$output"
fi
Might be a bit easier :-)
from homeshick.
What about stderr?
output="$(git clone $git_repo $repo_path 2>&1)"
if [ $? != 0 ]; then
err "Unable to clone $git_repo. Git says: $output"
fi
from homeshick.
(in that case we also could omit the --quiet
flag, since more information on error is actually better)
from homeshick.
Oh yes, that too of course. I just realized that we don't need the exit $?
at all. Not sure why I thought the subshell would exit with 0 otherwise.
from homeshick.
git
seems to print all output to stderr (!?), so redirecting only stdout to /dev/null and let errors pass through is not possible.
from homeshick.
That said, i would prefer a more verbose output, especially when updating submodules, since i still don't fully trust git's submodule functionality.
from homeshick.
Maybe we can introduce a --verbose
switch. Saying git submodule
cannot be trusted is a very subjective argument for outputting unimportant information to the console.
In addition, knowing how the submodule functionality operates I have to disagree.
I think I will implement this. (unless you can provide a stronger argument?)
from homeshick.
Go ahead 👍
from homeshick.
Oh ffs. I get my confusion now. Guess what?
#!/bin/bash
function fn {
output1=$(test -e nonexistent)
echo $? # Outputs 1
local output2=$(test -e nonexistent)
echo $? # Outputs 0
local output3
output3=$(test -e nonexistent)
echo $? # Outputs 1
}
fn
The local
keyword is a command that changes the last exit code. This is why I sometimes couldn't get the proper exit code.
from homeshick.
Related Issues (20)
- homeshick `cd` command doesn't work on Homebrew install HOT 1
- New version? HOT 4
- Homeshick gives a help message and crashes my zsh session HOT 1
- Don't commit home folder HOT 1
- Dependancy Issue with ASDF HOT 5
- Add dry run mode HOT 2
- Homeshick doesnt prompt me upon refresh HOT 1
- Clone command should use git@github as the remote origin HOT 4
- Always says my castles are outdated no matter I just refreshed HOT 5
- Cloning takes forever for simple repos HOT 1
- Automatically symlink submodules of castle as a single symlink to toplevel directory HOT 4
- homeshick doesn't track nor link .git directories HOT 6
- Your package destroyed all of my dotfiles HOT 13
- 解决zsh补全msfvenom出现_values:compvalues:11: not enough arguments(参数不足)的问题 HOT 2
- Clone/pull on large repositories/submodules: Recursion and depth HOT 2
- New version? HOT 1
- Clone to directory, and set working directory, like git -C directory HOT 2
- Relative symlinks do not allow git templatedir to live in castle HOT 3
- Naming differences HOT 4
- Installing homeschick broke the terminal HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homeshick.