1654: "Universal Install Script"

This forum is for the individual discussion thread that goes with each new comic.

Moderators: Moderators General, Prelates, Magistrates

User avatar
Soupspoon
You have done something you shouldn't. Or are about to.
Posts: 3368
Joined: Thu Jan 28, 2016 7:00 pm UTC
Location: 53-1

Re: 1654: "Universal Install Script"

Postby Soupspoon » Sun Mar 13, 2016 5:06 am UTC

Sandor wrote:
svchost wrote:The real question is: Where is zypper?

Or "rpm --install"?

Writing a bash script and giving it a ".sh" extension as if it were a Bourne script always strikes me as slightly wrong. I do it anyway, because ".bash" as a file extension seems wronger, although I don't know why (too many characters?)

When my preferred flavour of shell/script was tcsh1 I'm not sure I ever made them ".tcsh" - but then I also don't think I ever had the wisdom to add any extension, except maybe for the odd ironic '.bat' (lowercase!). (Double-points if the .bat file worked equivalently upon both platforms types... Triple-points if it didn't require something external like an alias substitution to handle "REM"s, in the unix environment... ;) )

1 Someone set it up for me, before I realised there were choices, and I was happy enough to go along with it and then just reproduced it during later migrations, for those few years it was still fresh in my mind.

ps.02
Posts: 378
Joined: Fri Apr 05, 2013 8:02 pm UTC

Re: 1654: "Universal Install Script"

Postby ps.02 » Sun Mar 13, 2016 10:12 am UTC

Sandor wrote:Writing a bash script and giving it a ".sh" extension as if it were a Bourne script always strikes me as slightly wrong. I do it anyway, because ".bash" as a file extension seems wronger, although I don't know why (too many characters?)

What is this "extension" of which you speak? You mean some arbitrary suffix tacked onto an executable file name? Why would you want that? Surely anyone who actually cares what language it's written in would know about such advanced tools as head or view.

User avatar
Soupspoon
You have done something you shouldn't. Or are about to.
Posts: 3368
Joined: Thu Jan 28, 2016 7:00 pm UTC
Location: 53-1

Re: 1654: "Universal Install Script"

Postby Soupspoon » Sun Mar 13, 2016 11:34 am UTC

ps.02 wrote:What is this "extension" of which you speak? You mean some arbitrary suffix tacked onto an executable file name? Why would you want that? Surely anyone who actually cares what language it's written in would know about such advanced tools as head or view.

To be honest, I'm generally with you about forgetting extensions (on systems where magic numbers matter more than the extension as primary metadata for the file) especially when it's my own private setup, in not making files ('u+x'ed) any more descriptive than "do" (c.f. "DO.BAT" under DOS - and then also DO2.BAT, etc).

But a simple 'ls' (or a slightly more complicated 'ls -als'/whatever, the -l at least being mostly engrained into my muscle-memory) giving an overview of a directory contents is made that little easier to comprehend when given some sort of immediate context. (On top of traditionally unsuffixed files such as 'makefile' whose purposes is either obvious from habitual use or else just plain wrong, thanks to someone else's misunderstanding...) The problem now is to be descriptive enough (in both name and - optional but possible - extension) without creating line-wrapped filenames. And whilst sticking to an 8.3 limit is good for portability (less necessary than it used to be!), also avoid squashng.it into unrdable.txt that you (or another) don't fully understand at a later date... But now if you'll kindly introduce me to your grandmother, I'll now proceed to demonstrate to her my own favoured method for sucking eggs, also... ;)

(I'm completely aware of the 'head' command (though don't use it much in a multi-file situation, to reveal just the hashbang line, if any, because it's much more unwieldy than the -l listing), but I'll admit that 'view' is new to me. When I'm back on my *nix environment I'll see if it exists on my system, but until then I'm just getting pointers to it, in my friendly neighbourhood search engine, as a vi option; which is probably not the command you mean. (Sorry, I'm not a vi person, but I know there's a completely different board and thread for this!))

User avatar
Flumble
Yes Man
Posts: 1998
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: 1654: "Universal Install Script"

Postby Flumble » Sun Mar 13, 2016 5:31 pm UTC

Soupspoon wrote:But a simple 'ls' (or a slightly more complicated 'ls -als'/whatever, the -l at least being mostly engrained into my muscle-memory)

I usually whip it to get better results, ls -lash.


ps.02 wrote:What is this "extension" of which you speak? You mean some arbitrary suffix tacked onto an executable file name? Why would you want that? Surely anyone who actually cares what language it's written in would know about such advanced tools as head or view.

I'd say compiled code doesn't need an extension (although it would make sense sine there are multiple OSes with different executable formats), but all those 'executable' files that need to be fired by some interpreter/compiler-executor benefit from telling you which program to use via their filename. Because the filename is guaranteed to be text rather than binary.

If only there were some universal container format that tells us about the type of a file. Preferably one where the type doesn't have to be a constant type, but can be a function type defining the inputs/environment and the output, if any.
The usual shell script could have the type (SHEnv,String)→String instead of a first line #!/bin/sh. (or (SHEnv,String)→(String,FileSystem) if we're going full functional)

User avatar
Eternal Density
Posts: 5544
Joined: Thu Oct 02, 2008 12:37 am UTC
Contact:

Re: 1654: "Universal Install Script"

Postby Eternal Density » Sun Mar 13, 2016 9:00 pm UTC

sfmans wrote:
Reecer6 wrote:I don't think this shell script accounts for the fact that none of these things will help me download the OS I will use to download them on, and I'm kind of stuck at ground zero.


I've just spent a few happy minutes musing on what, er, distinctive features an xkcd distro would have ...

I hope this becomes a comic at some point.
Play the game of Time! castle.chirpingmustard.com Hotdog Vending Supplier But what is this?
In the Marvel vs. DC film-making war, we're all winners.

User avatar
Eternal Density
Posts: 5544
Joined: Thu Oct 02, 2008 12:37 am UTC
Contact:

Re: 1654: "Universal Install Script"

Postby Eternal Density » Sun Mar 13, 2016 10:15 pm UTC

I don't give my bash script files extensions.
Play the game of Time! castle.chirpingmustard.com Hotdog Vending Supplier But what is this?
In the Marvel vs. DC film-making war, we're all winners.

ps.02
Posts: 378
Joined: Fri Apr 05, 2013 8:02 pm UTC

Re: 1654: "Universal Install Script"

Postby ps.02 » Sun Mar 13, 2016 11:01 pm UTC

Soupspoon wrote:...an overview of a directory contents is made that little easier to comprehend when given some sort of immediate context.

This assumes that there's any utility in knowing what language a given executable is written in. That's what I challenge. If I write a script and name it do-a-thing, I or anyone else can see "oh, here's an executable whose purpose is to do a thing." When I later need to do a thing, of course I can raise the question in my mind of whether do-a-thing will be suitable. But that question has little to do with its implementation language. I mean, it's going to parse command line options, have input files, use standard input if there are no input files, indicate success or failure using zero and non-zero return values ... the usual. No matter which language I chose. So really, whether do-a-thing will be suitable has a lot more to do with who wrote it, and whether I trust that person to have done a good job. And by that logic, I should have named it do-a-thing.ps.02. (Which I don't.)

I'll admit that 'view' is new to me. When I'm back on my *nix environment I'll see if it exists on my system, but until then I'm just getting pointers to it, in my friendly neighbourhood search engine, as a vi option; which is probably not the command you mean.

It is. view is really just an alias for vi which puts it in read-only mode. So you can use it to view a file's contents, with all the vi search and navigation commands. I don't use it much, actually, because the less pager has a lot of those same search and navigation capabilities, even using many of the same key-bindings.

(And by the way, I don't think in today's world you really need to worry about being yelled at by the owners of the Unix trademark. If you need a term for "various systems derived from either AT&T or Berkeley Unix™", I think you can just say Unix. Or, if you're looking for a glob pattern to match various OS names like Linux, Solaris, IRIX, OS X, HP/UX and AIX, you'll have to find something a lot more general than *nix, which matches none of these.)

User avatar
Soupspoon
You have done something you shouldn't. Or are about to.
Posts: 3368
Joined: Thu Jan 28, 2016 7:00 pm UTC
Location: 53-1

Re: 1654: "Universal Install Script"

Postby Soupspoon » Sun Mar 13, 2016 11:59 pm UTC

ps.02 wrote:(And by the way, I don't think in today's world you really need to worry about being yelled at by the owners of the Unix trademark. If you need a term for "various systems derived from either AT&T or Berkeley Unix™", I think you can just say Unix. Or, if you're looking for a glob pattern to match various OS names like Linux, Solaris, IRIX, OS X, HP/UX and AIX, you'll have to find something a lot more general than *nix, which matches none of these.)

Force of habit. (And, even back in the day, I really wanted to use something that would match both "Unix" and "Linux", but the convention was already in place.)

(It also took quite a while after it became Ok again, to remember that I could use something roughly Lempel-Ziv-Welch-ish, publicly, without fear of treading on the toes of the apparent patent, given those ten years or so of uncertainty from '94 to '04. Yeah, nothing I did was likely to be labelled/pursued as an infringement, but it was always something at the back of people's minds, IME.)

xtifr
Posts: 322
Joined: Wed Oct 01, 2008 6:38 pm UTC

Re: 1654: "Universal Install Script"

Postby xtifr » Mon Mar 14, 2016 8:45 am UTC

Yeah, I certainly don't see any point in using extensions with executables, whether they're scripts or not. For one thing, if you change the implementation language when you add features later, it's simply a waste of time to have to check for all the references in other scripts and whatnots and edit them to use a new extension. Not to mention retraining my fingers. Functionally, there's no difference between a shell script, a python script, and a compiled binary from some random implementation language. (Unless you've never heard of the chmod command, I suppose...)

If I'm curious about the code for some reason—I want to adjust something or know how one of the options works, and want to know whether I'm going to have to download the source separately—I use file(1).

BTW: I think, from some editing I had to do while writing this, that the days of madness are upon us. :)
"[T]he author has followed the usual practice of contemporary books on graph theory, namely to use words that are similar but not identical to the terms used in other books on graph theory."
-- Donald Knuth, The Art of Computer Programming, Vol I, 3rd ed.

ps.02
Posts: 378
Joined: Fri Apr 05, 2013 8:02 pm UTC

Re: 1654: "Universal Install Script"

Postby ps.02 » Mon Mar 14, 2016 11:53 am UTC

Soupspoon wrote:(It also took quite a while after it became Ok again, to remember that I could use something roughly Lempel-Ziv-Welch-ish, publicly, without fear of treading on the toes of the apparent patent, given those ten years or so of uncertainty from '94 to '04.

Surely this explains the explosion in popularity of GIF images on the modern Internet, yes?
(I mean, not that all software patents are as irrelevant as LZW - it's been nice to be able to freely use RSA again....)

User avatar
orthogon
Posts: 2900
Joined: Thu May 17, 2012 7:52 am UTC
Location: The Airy 1830 ellipsoid

Re: 1654: "Universal Install Script"

Postby orthogon » Mon Mar 14, 2016 12:08 pm UTC

ps.02 wrote:
Sandor wrote:Writing a bash script and giving it a ".sh" extension as if it were a Bourne script always strikes me as slightly wrong. I do it anyway, because ".bash" as a file extension seems wronger, although I don't know why (too many characters?)

What is this "extension" of which you speak? You mean some arbitrary suffix tacked onto an executable file name? Why would you want that? Surely anyone who actually cares what language it's written in would know about such advanced tools as head or view.

If you're going to use head (or, worse, cat) on a file that might or might not be binary, you'd better also know about such advanced tools as "stty sane".
xtifr wrote:... and orthogon merely sounds undecided.

User avatar
Soupspoon
You have done something you shouldn't. Or are about to.
Posts: 3368
Joined: Thu Jan 28, 2016 7:00 pm UTC
Location: 53-1

Re: 1654: "Universal Install Script"

Postby Soupspoon » Mon Mar 14, 2016 12:41 pm UTC

ps.02 wrote:Surely this explains the explosion in popularity of GIF images on the modern Internet, yes?
Oh, I don't bother too much about the GIF format (well, except when making animated GIFs, where that's actually the most portable solution for a particular utilisation), but I've found the LZW method of index-free streaming compression/decompression to be an elegant and handy solution. There are better ways, often, but I do have a soft spot for tightly hand-coding this particular process to match a particular purpose.

Specifically:
Spoiler:
If it's guaranteed to be a stream of printable 7-bit ASCII characters, knowing that you can unequivocally use the non-printables (including character 127) and eighth-bit values (unless you're also squashing 8x7-bits into 7x8-bits, along the way) to signpost and codify non-literal table-keys for transmission, it saves on fuss like having to reserve one value as a meta value (and, presumably, reserving "meta-meta" to indicate the meta as literal, whenever that crops up) and thus spreads out such metas amongst multiple fixed/variable-length sequence-encodings, seriously cutting down on the speed at which novel table values break through any given current meta-sequence length, forcing either a table pruning or meta-sequence lengthening process to prevent overflows.

On the other hand, if it's a particular file format, such as anything XML-ish (with or without any other assumed stream value restrictions, as above!), you can procedurally hardcode/preload your tables at each end with suitable variations on the <..., </..., ...> and .../> entries (which will be common!), leaving you free to use purely non-literal instances of these in the stream your future table-keys.

(I probably spend more time troubleshooting them than is strictly necessary, compared with a prebuilt library for the same purpose, fully audited and optimised at least for all general situations, but I like to at least give it a try...)

User avatar
Soupspoon
You have done something you shouldn't. Or are about to.
Posts: 3368
Joined: Thu Jan 28, 2016 7:00 pm UTC
Location: 53-1

Re: 1654: "Universal Install Script"

Postby Soupspoon » Mon Mar 14, 2016 12:56 pm UTC

Soupspoon wrote:
ps.02 wrote:Surely this explains the explosion in popularity of GIF images on the modern Internet, yes?
Oh, I don't bother too much about the GIF format (well, except when making animated GIFs, where that's actually the most portable solution for a particular utilisation), but I've found the LZW method of index-free streaming compression/decompression to be an elegant and handy solution. There are better ways, often, but I do have a soft spot for tightly hand-coding this particular process to match a particular purpose.

Specifically:
Spoiler:
If it's guaranteed to be a stream of printable 7-bit ASCII characters, knowing that you can unequivocally use the non-printables (including character 127) and eighth-bit values (unless you're also squashing 8x7-bits into 7x8-bits, along the way) to signpost and codify non-literal table-keys for transmission, it saves on fuss like having to reserve one value as a meta value (and, presumably, reserving "meta-meta" to indicate the meta as literal, whenever that crops up) and thus spreads out such metas amongst multiple fixed/variable-length sequence-encodings, seriously cutting down on the speed at which novel table values break through any given current meta-sequence length, forcing either a table pruning or meta-sequence lengthening process to prevent overflows.

On the other hand, if it's a particular file format, such as anything XML-ish (with or without any other assumed stream value restrictions, as above!), you can procedurally hardcode/preload your tables at each end with suitable variations on the <..., </..., ...> and .../> entries (which will be common!), leaving you free to use purely non-literal instances of these in the stream your future table-keys.

(I probably spend more time troubleshooting them than is strictly necessary, compared with a prebuilt library for the same purpose, fully audited and optimised at least for all general situations, but I like to at least give it a try...)



orthogon wrote:If you're going to use head (or, worse, cat) on a file that might or might not be binary, you'd better also know about such advanced tools as "stty sane".
...indeed. I wasn't that bothered about the terminal-beeps from the ^G and other whitespace/newline-spamming, but a number of times I accidentally (or recklessly) catted binary files, back in the day, and then found my terminal (having interpreted one of the non-printables as something meta) now displaying everything exclusively in some alternate charset. (I was too lazy to work out what the switch-back code actually was, to echo it directly. I just found, by trial and error, another useful and accessible binary file where the meta (whatever it was) to switch back again featured nearer the end than any possible switch-to. I probably then aliased it to an easy command to type 'blind', so that I didn't have to close and re-open the terminal session.)

But it was probably just a peculiarity of the PC terminal software of that time, that caused this. I don't think I had an issue with 'codepage switching' (which is probably what it was) on the rather more simplistic VT220s/whatever, nor with the standard 'xterm' tty windows (which, if so 'ruined', could have been abandoned and replaced without closing the session) on the X Windows boxes. Ah, nostalgia! Don't think I've ever done this kind of thing on any modern Linux machine, thus unsure if it's a problem most people here would even have seen, but I'm not sure if that's due to good luck or good judgement.

Velo Steve
Posts: 30
Joined: Thu May 05, 2011 12:27 am UTC

Re: 1654: "Universal Install Script"

Postby Velo Steve » Sun Apr 22, 2018 12:57 am UTC

I was really expecting

Code: Select all

conda install "$1" &

I guess conda has grown a lot in popularity over the last two years, though it existed well before the comic.

Or am I missing some reason it doesn't belong in that list? [Yeah, I know it's an ancient thread.]


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: taixzo, Thesh, ucim and 40 guests