DBMasterC
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Downloads
Posts posted by DBMasterC
-
-
My hacky solution involves abuse of the switch construct. While it adds some bloat, it does allow you to return early. Whether or not it's preferable to goto is in the eye of the beholder.
sub: doMath(&success) switch(0) { case(0): success = -1 //default is failure local math = 0; if (somethingbad==1) break; //will exit the switch{}, hitting your return if (somethingelse == 1) break; math = 2+2; success = 1; //completed } return;
Script 'system' call not jiving with documentation
in Power PMAC
Posted
I've been investigating using the script System call to invoke some background C programs and do some work, however I'm running into behavior contrary to the documentation.
The manual includes this example:
However, when executed, I get an error that
This isn't super surprising; sh is being passed the entire string and is interpreting it as the executable to find, rather than as an executable followed by arguments. If I just move the quote:
this works fine - the executable is invoked with the right arguments.
Now, the crux is the other feature advertised in the manual, the ability to pass a formatted string with arguments to system. Ideally, I'd do something like
This doesn't work for two reasons:
The file not being found is expected per the initial issue. However, given that, what I'd _expect_ to not be found is
rather than the full pattern.
How can I format a command to the system from script? Am I doing something wrong? Is the manual wrong?