swcarpentry / shell-novice

The Unix Shell
http://swcarpentry.github.io/shell-novice/
Other
391 stars 979 forks source link

ls does not print names in alphabetical order on all platforms #744

Closed loz-hurst closed 6 years ago

loz-hurst commented 6 years ago

In episode 2 (_episodes/02-filedir.m) it says "ls prints the names of the files and directories in the current directory in alphabetical order". On Mac this is NOT the case - files and directories are in asciibetical order (A-Z before a-z).

For example: `` $ mkdir A b C

$ touch d E f

$ ls -F A/ C/ E b/ d f ``

On Linux the man pages does state Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐fied.. So this is true but ONLY ON THAT PLATFORM.

On Mac the man pages does not state how the files will be ordered if no (sorting) arguments are given - so it cannot be presumed that asciibetical is the guaranteed order.

This is a BSD vs Linux core tools issue, I believe.

colinmorris commented 6 years ago

Any thoughts on how you'd improve this? I think explaining the subtle difference between platforms would be too much technical detail. But I'm not opposed to just dropping the phrase "in alphabetical order".

It seems like the "arranged neatly into columns" part is also technically an overreach. I was curious enough to look it up. The POSIX spec says:

The default format shall be to list one entry per line to standard output; the exceptions are to terminals or when one of the -C, [XSI] [Option Start] -m, or -x [Option End] options is specified. If the output is to a terminal, the format is implementation-defined.

But I feel like these are both pretty harmless white lies.

loz-hurst commented 6 years ago

I disagree, in my mind there's a big difference between glossing over intricate details but maintaining factual accracy (e.g. by just not "going there") and saying something which is factually, and demonstrably to the majority of researchers at my University who are Mac users, untrue. To have factual inaccracies creeping into the training materials is potentially going to plant the seeds of doubt about the authority of the rest of the material in delegates minds (especailly when the audience is primarially drawn from the scientific and research community, at lot of whom conigtive processes are orientated around "facts" and a black-and-white true/false view of e.g. published papers).

I'm not sure why we are mentioning this at all, at this stage and level of training? The current wording is this:

ls prints the names of the files and directories in the current directory in alphabetical order, arranged neatly into columns.

This sentence presents four"facts" to the trainee:

Given the emphasis on managing congnitive load to promote learning in the instructors training, do the last 2 facts need to be mentioned at all?

Personally, I think would be preferable at the start of a paragraph that then goes stright into explaining flags - another new concept - to avoid overloading the students with unnecessary detail at this stage:

ls prints the names of the files and directories in the current directory.

If the prevailing view is that the extra "facts" should be retained then I would propose that it is re-worded to say that ls is capable of sorting and arranging the output in different ways using other flags (although that would be better put after the -F flag (and the concept of flags generally) is introduced.

e.g.:

ls prints the names of the files and directories in the current directory in alphabetical order, arranged neatly into columns. We can make its output more comprehensible by using the flag -F (also known as a switch or an option) , which tells ls to add a marker to file and directory names to indicate what they are. A trailing / indicates that this is a directory. Other flags are available that can sort the files and rearrange the output. Depending on your settings, it might also use colors to indicate whether each entry is a file or directory.

I've also changed the wording "Depending on your terminal, " to "Depending on your setup, " as I feel this is more accurate - colour depends not only on terminal support but also (usually) the default aliases - on RedHat colour is default, on Debian it is not, for example.

Bottom line, I agree that we should not overburden the material (or students) with intricate detail but that is no excuse for knowingly presenting incorrect information as facts ("white lies" as you put it).

Laurence

gcapes commented 6 years ago

I would think the easiest solution to this is to remove the last two points, simply cutting short that problem sentence:

ls prints the names of the files and directories in the current directory. in alphabetical order, arranged neatly into columns.

I don't think there's much to be gained by bloating the lesson with details of how the behaviour on system X is different to system Y.

loz-hurst commented 6 years ago

Agreed. I'll sort out a merge request.