-
Notifications
You must be signed in to change notification settings - Fork 6
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
Warn users when shell lines get too long? #630
Comments
Sorry. This isn't going to get addressed for the 4.15 release. There are a number of issues, some of which you've alluded to
Options are (once we decide what 'too long' means)
[*] I thought we tracked whether a parameter supported a stack, but it looks like we don't (it requires parsing the ahelp XML file which is probably why I haven't bothered so far, but it could be done) |
I'm OK with not addressing this in 4.15, but I do think it's worthwhile looking at at some point. Out of the three options, I'd go with "error out if we find a string is too long". This is a rare condition (otherwise we'd have heard more complaints about it) and sometimes even indicates a user error (like my example). In many cases, it will be straightforward for the user to address, in particular if the error message says helpful things like " In some cases this can be avoided by using a stack file as input instead - see That would be way simpler for us to program and maintain and avoids any risk of introducing even more subtle bugs that happen only when long lines are magically converted to stack files, as we'll never be able to get full tests for that. |
Unfortunately I don't know what "too long" is. Is it 2048, 1024, 1025, Thursday, or something else? Is it per parameter or the overall length, or can you trigger the per-parameter length even if the overall command-string is not too log? Without information on this we can't do anything sensible here, I claim™. |
Compare the following two commands and their outputs using standard CIAO syntax in the shell:
The latter is the same instruction, just with more
0
added. If run in e.g. a jupyter notebook asrt.dmextract( ... long string here ...)
I just get a "notebook kernel died" which is even less informative than the "zsh: abort" I get on the command line. Since Python allows almost arbitrarily long strings and string manipulation is easy, it's natural to build up e.g. regions on the sky as long strings as I've done for the background region here. In fact, it's happened to me in several cases where I I simply build up a string from a few elements because it's easy and fast and readable and works well for simple cases and then later run the same code on a more complex region and get crashes.All the handling in Python works fine. I can set `rt.dmextract.bkg=" ... long string ...", but when I then run dmextract, the entire session crashes. I suggest to check the number of characters in the strings before it is passed to the command line, i.e. before https://github.com/cxcsds/ciao-contrib/blob/main/ciao_contrib/runtool.py#L1808
with a helpful error message like "Parameters exceed string length excepted by CIAO tools and your shell." or maybe even "Parameters exceed string length excepted by CIAO tools and your shell. Consider the use of stackfiles and region files instead of long input strings, see https:\ ... ".
Question: Is that a good idea?
Note 1: The example above is a slightly simplified version of what I did in practice. In reality, I'm not just adding 0, but I reach the line length by having more complex source and background regions. I just made this example to show that the problem is really with the length of the string and not the regions I select.
Note 2: This issue is about adding a helpful error message and preventing crashes of the entire session. I am not asking for specific advice in may case, because I discovered that, due to some unrelated bug, the regions I exclude are the wrong regions anyway...
Note 3: I don't know what the max length is and it might depend on the shell, but it's not hard to just try that out on bash and zsh and Mac and Linux and just take the smallest of those numbers. That will cover 99% of all users and still allows reasonably long strings for normal applications. I don't think we need to be more clever than that.
Note 4: While I looked at dmextract, which is wrapped by
CIAOToolParFile
the same applies probably to the other classes.The text was updated successfully, but these errors were encountered: