Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get exit code on cp/rsync #192

Open
zzzbatmand opened this issue Jul 26, 2022 · 4 comments
Open

Unable to get exit code on cp/rsync #192

zzzbatmand opened this issue Jul 26, 2022 · 4 comments

Comments

@zzzbatmand
Copy link

I want to see if a cp/rsync fails, but when I try to use $? after the command has failed (sys.exit(2)) then I just get a 0.

OS: Windows WSL

me@PC:/mnt/c/Users/me/Documents/TMP/fw# rshell -p /dev/ttyS7 cp -r ./Pycom/* /flash
Using buffer-size of 32
Connecting to /dev/ttyS7 (buffer-size 32)...
Trying to connect to REPL  connected
Retrieving sysname ... GPy
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /flash/
Setting time ... Jul 26, 2022 10:27:05
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
timed out or error in transfer to remote: b''
me@PC:/mnt/c/Users/me/Documents/TMP/fw# echo $?
0

Sidenote:
The way I tested this, was by disconnecting the serial wires doing upload.
Sometimes this caused the program to just hit an infinite loop.

@neopostmodern
Copy link

Same on Ubuntu – this is a major bummer for me because I use this in scripts with set -o errexit and wrongly assumed the whole thing was successful when rshell cp had actually failed somewhere further up in the script.

@dhylands
Copy link
Owner

dhylands commented Dec 4, 2024

Thanks for bring this up. This isn't a path I had considered. I'll see what I can do to fix this.

@dhylands
Copy link
Owner

dhylands commented Dec 4, 2024

I think I've fixed it so that if that if you do rshell some-command and some-command encounters an error then the exit code will be non-zero (in version 0.0.36)

@neopostmodern
Copy link

Thank you! I'll be working with this in the upcoming week and will report back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants