Comments (4)
Thanks for pointing this out!
My view on unique return codes somewhat differs from yours. I think that a caller should not care much about the reason of failure, rather than the fact of failure. I.e. an automated tool has no means to correct an error.
If you feel that this feature if absolutely necessary, I'll add it. But in mean time I've fixed the code in my way :) See the v0.6.1 tag.
Regards,
Maksim.
from rl78flash.
I tested 0.6.1.
Indeed it is not needed to have an individual error code for each situation.
Like you did with EINVAL, EIO, ECANCELED is enough.
The expected use case is that rl78flash will be called from an automatic sequence which will be interrupted on error. The operator will be able to see the output of stdout and stderr and see what happened.
It works ok - I'm not able to find any situation when an error occurs but code is 0. Good.
Small remark:
When an argument like -b -m or -t is used incorrectly (wrong value or something) then usage is written to stdout and error code is returned but nothing is written to stderr that parameter was used incorrectly.
Also when running rl78flash -h then usage is displayed and error code is returned.
I think that if -h parameter was used then showing the help was the expected behavior and shouldn't be treated as an error.
How about something like this:
case 'h':
case '?':
printf("%s", usage);
return 0;
default:
printf("%s", usage);
return ECANCELED;
from rl78flash.
Thanks for testing!
Small remark:
When an argument like -b -m or -t is used incorrectly (wrong value or something) then usage is written to stdout and error code is returned but nothing is written to stderr that parameter was used incorrectly.
Ok. I'll fix this.
Also when running rl78flash -h then usage is displayed and error code is returned.
I think that if -h parameter was used then showing the help was the expected behavior and shouldn't be treated as an error.
I agree, that showing the help is not a error case. But help is usually requested by a user, not a script.
So returning non-zero exit code to a user in an interactive shell is not an issue, I believe. But what if -h
sneaks into the argument list in a non-interactive script? If the app returns 0, then the script will consider flashing successful, but rl78flash
exited without any flashing done. So this is why I decided to return ECANCELED even on help request. If a user wants to get help message in a script, he can always ignore the exit code to make this action explicit.
Regards,
Maksim.
from rl78flash.
I agree, that showing the help is not a error case. But help is usually requested by a user, not a script.
So returning non-zero exit code to a user in an interactive shell is not an issue, I believe. But what if -h sneaks into the argument list in a non-interactive script? If the app returns 0, then the script will consider flashing successful, butrl78flash
exited without any flashing done. So this is why I decided to return ECANCELED even on help request. If a user wants to get help message in a script, he can always ignore the exit code to make this action explicit.
Ok, this makes sense. I understand it.
In fact, my wrapper for rl78flash
which my tools will use doesn't even give the possibility to select -h
.
from rl78flash.
Related Issues (20)
- Doesn't compile on RaspberryPi HOT 1
- TOOL0 needs 1k pull-up HOT 9
- Error code when failed verification HOT 1
- Fail on empty line of s-record. HOT 1
- Misleading error message in case too big s-record file
- Portiing uIP for YRBRX62NP HOT 2
- Entering programming mode HOT 3
- The mode settings on Windows and Linux do not work the same way.
- protocol C bug HOT 9
- protocol C bug HOT 1
- rl78s-hw.sch file can not open normaly. HOT 1
- Windows FAILED baud rate set HOT 6
- Initilization failed, error at rl78_recv HOT 2
- Input file matching full data flash size is rejected HOT 1
- RTS reset issue HOT 1
- Windows Failed HOT 4
- FT232RL causes 'Synchronization failed' error with -b 250000 or 500000 or 1000000 option (Windows) HOT 12
- Not able to program (no response from microcontroller?) HOT 8
- Data flash not programmed HOT 10
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 rl78flash.