Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Would building or otherwise installing ls 8.25 and setting the automated regression system to use it (perhaps by putting it in a prepended PATH entry) be an option?
Is updating the automated regression system an option?
I don't think you can rely on specific output formats, especially when it comes to error messages. Your program has to perform the test whether the file exists or not.
Other example: There have been heated discussions how ls should treat nonprintable or otherwise special characters in filenames. A recent revision of ls changed the behaviour. Again, the bottom line is that the output of ls is not standardized, and that you should not make assumptions.
It's not too hard to test for the existence of a file in Bash:
Code:
[ -e foo ] && echo foo exists
Last edited by berndbausch; 09-22-2020 at 08:28 PM.
It's a simple search to identify the relevant commit and answer that question.
Your simplest fix is probably to quote the filenames in your expected output, but the better fix is to use a mechanism specifically intended to identify if a file exists (as per berndbausch's post), and which doesn't rely on a brittle error message.
It's for an automated regression system with expected output.
You must not rely on the output of ls, but use nullglob or similar or other tool (written in perl/python/awk/shell/whatever).
from the other hand you may try to remove ' from the output with sed or tr or something else.
You must not rely on the output of ls, but use nullglob or similar or other tool (written in perl/python/awk/shell/whatever).
from the other hand you may try to remove ' from the output with sed or tr or something else.
An outstanding suggestion! Removing the quotes with sed is an excellent idea!
I assume the "automated regression system" shells out to ls and parses its output, and that for bad reasons that are unfortunately common in the industry, that cannot be changed.
bagpussnz: The "correct" solution would obviously be to update the automated regression system. I assume that there are reasons (technical, bureaucratic, or otherwise) why you can't do that?
It's for an automated regression system with expected output.
So the automated regression system has done it's job and detected a change.
Despite what @dugan suggests "for bad reasons that are unfortunately common in the industry, that cannot be changed", I fail to understand why it is needed to bend the new 'ls' output to match the old behaviour.
I consider the new behaviour to be better (e.g. differentiating a file name containing a space).
If that is not acceptable, stick with the old version.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.