RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

Change Shell Handler Signature Completely

Open LudwigKnuepfer opened this issue 12 years ago • 34 comments

To increase similarity with regular shells, the handler signature could be changed to int handler(int argc, char **argv);.

The return value 0 would indicate success, anything else would be treated as an error.

The shell would need to be changed to iterate over the whole string with strtok, counting the parameters and to check the return value of the handler. If an error occurred the shell could print a message.

All shell commands would need to be updated for the new signature.

Pros:

  • shell commands can communicate errors more easily (just return 1)
  • no need for use of the unfamiliar strtok within the commands
  • easier portability of existing commands

Cons:

  • commands loose the ability to sscanf through parameters expecting spaces

LudwigKnuepfer avatar Feb 15 '14 10:02 LudwigKnuepfer

+1

mehlis avatar Feb 15 '14 10:02 mehlis

+1

OlegHahm avatar Feb 15 '14 17:02 OlegHahm

+1 if quoting is allowed, otherwise I see little use in argc and argv.

Kijewski avatar Feb 15 '14 22:02 Kijewski

this would simplify all shell handlers, so adding strtok in one place is is good idea.

mehlis avatar Feb 16 '14 10:02 mehlis

this was it. +1 with quoting.

kaspar030 avatar Feb 21 '14 15:02 kaspar030

All in favor of quoting support: would parsing " chars be enough, or would you expect the full range (i.e.: "'\, did I miss anything?) of characters to work?

LudwigKnuepfer avatar Feb 21 '14 16:02 LudwigKnuepfer

" or ' and escaping using \...

kaspar030 avatar Feb 21 '14 16:02 kaspar030

I guess the latter one would be overkill, but you get a +2 from me if you program both with a compile time switch. :)

Kijewski avatar Feb 21 '14 16:02 Kijewski

Well then, start with just ". We can improve as needed. ;)

kaspar030 avatar Feb 21 '14 16:02 kaspar030

I'll sketch up a little function.

Kijewski avatar Feb 21 '14 17:02 Kijewski

@Kijewski Stealing from the newbies, are you? ;-)

LudwigKnuepfer avatar Feb 21 '14 17:02 LudwigKnuepfer

@LudwigOrtmann, of course I am. Stealing the easy tasks is my style. :dancers: Anyways, how many newbies do you count in this thread? :)

Kijewski avatar Feb 21 '14 17:02 Kijewski

None so far .. but seriously - in case you did not realize - the newbie tag was for potential gsoc candidates - those are not to be expected yet. And also: I'm absolutely fine with you implementing this =)

LudwigKnuepfer avatar Feb 21 '14 17:02 LudwigKnuepfer

Sorry, I did not know that. :-/ Anyhow ... #760. I'd bet that I introduced some errors.

Kijewski avatar Feb 21 '14 18:02 Kijewski

Nothing to be sorry about - it is not meant to prevent anyone else from fixing, just to point the newbies to these tickets.

LudwigKnuepfer avatar Feb 21 '14 18:02 LudwigKnuepfer

@Kijewski I accept you as gsoc candidate :+1:

mehlis avatar Feb 21 '14 19:02 mehlis

OK, now that #760 has been merged, the remaining missing features from this issue are:

  • change of the return type
  • escaping using ' and \

LudwigKnuepfer avatar Feb 26 '14 16:02 LudwigKnuepfer

Do we consider these items as required?

OlegHahm avatar May 26 '14 12:05 OlegHahm

Which items?

LudwigKnuepfer avatar Jun 02 '14 08:06 LudwigKnuepfer

Sorry, that must have been pre-release stress.

What I wanted to say/ask was: Do we consider the not yet solved parts of this feature request as necessary, i.e. are handling of quotes and backslashes and return values a must? (Keeping in mind that we will have a real (aka POSIX compliant) shell soon, aren't we @authmillenon? ;-))

OlegHahm avatar Jun 02 '14 08:06 OlegHahm