What does shasum's --portable option do?

5

The shasum utility has a a -p/--portable option with the following description:

-p, --portable     read files in portable mode
                   produces same digest on Windows/Unix/Mac

I've never seen the inclusion this option change the digest of a file, and I'm not really sure what effect it's supposed to have either. What is this "portable mode" of reading files?

Flambino

Posted 2017-02-19T12:56:53.150

Reputation: 733

1Takes in account different EOL characters? – DavidPostill – 2017-02-19T14:08:56.097

1@DavidPostill Maybe, though that'd be strange too. Different EOLs makes for different files, and thus they should have different digests, right? The platforms's EOLs doesn't seem like something shasum should try to interpret/coerce – Flambino – 2017-02-19T14:17:34.700

For what it's worth shasum says " -p, --portable read in portable mode (to be deprecated)

– DavidPostill – 2017-02-19T14:24:16.463

@DavidPostill Ah, didn't say that in my manpage for it. Only makes it more mysterious :) – Flambino – 2017-02-19T14:25:47.470

1Answer added ;) – DavidPostill – 2017-02-19T14:37:28.583

Answers

3

What is this "portable mode" of reading files?

For what it's worth shasum says:

-p, --portable read in portable mode (to be deprecated)

As far as I can tell (I am no perl expert) it appears to be there to take into account different EOL characters.

The source code says:

The sums are computed as described in FIPS PUB 180-2.  When checking, the
input should be a former output of this program.  The default mode is to
print a line with checksum, a character indicating type (`*' for binary,
`?' for portable, ` ' for text), and name for each FILE.

...

# Try to figure out if the OS is DOS-like.  If it is,
    # default to binary mode when reading files, unless
    # explicitly overriden by command line "--text" or
    # "--portable" options.

...

I'm happy for any perl experts to look at the complete source code and confirm my answer.

DavidPostill

Posted 2017-02-19T12:56:53.150

Reputation: 118 938

well, darn. Your hunch was right - still a strange feature, but alright. I'll wait a bit and see if anyone else has something to add, but I suspect the checkmark's yours – Flambino – 2017-02-19T14:39:14.797