https://www.explainxkcd.com/wiki/api.php?action=feedcontributions&user=162.158.91.195&feedformat=atomexplain xkcd - User contributions [en]2024-03-28T08:26:51ZUser contributionsMediaWiki 1.30.0https://www.explainxkcd.com/wiki/index.php?title=1654:_Universal_Install_Script&diff=1146981654: Universal Install Script2016-03-11T15:10:56Z<p>162.158.91.195: /* Explanation */</p>
<hr />
<div>{{comic<br />
| number = 1654<br />
| date = March 11, 2016<br />
| title = Universal Install Script<br />
| image = universal_install_script.png<br />
| titletext = The failures usually don't hurt anything, and if it installs several versions, it increases the chance that one of them is right. (Note: The 'yes' command and '2>/dev/null' are recommended additions.)<br />
}}<br />
<br />
==Explanation==<br />
{{incomplete|This is an initial summary. Please check the facts about the repositories, I am not 100% familiar with them. Maybe a note should be made of Steam's odd presence and the reason for "apt-get & sudo apt-get"? Something like "many standard popular repository programs (and Steam, a game platform, which usually is not used for most programs)"? I'm not sure how to word it. There need to be wiki links, and the list currently in the [[#Trivia]] section should be incorporated in the main explanation (with wiki links). Is there a joke on the name of the program which could be read like ''Installish'' and what is a ".sh" file. How would you execute this script on a program - like it is mentioned in the explain would result in that the programs name is replace with the "$1" when the script runs?}}<br />
<br />
Most users of computers today are used to simple, easy installation of programs. You just download a .exe or a .dmg, double click it, and do what it says. Sometimes you don't even have to install anything at all, and it runs withou any installation.<br />
<br />
However, when things are more "homebrew", for example downloading source code, things are more complicated. You have to work with "build environments" and "makefiles", and command line interfaces. To make this process simpler, there exist repositories of programs which host packages of source code and the things needed to build it. When you download the package, it automatically does most of the work of building the code into something executable. However, there are many such repositories, such as "pip" and "brew", among others listed in the comic. If you only know the name of a program or package, you may not know in which repository(ies) it resides.<br />
<br />
The script provided in the comic attempts to fix this problem, by giving a "universal install script". It accepts the name of a program when you run it as an argument. This value is then referenced as "$1" (argument number 1) for a large number of commands. Everywhere the script says "$1", it substitutes in the name of the package you gave it. The end result is the name being tried against a large number of software repositories and package managers, and hopefully, at least one of them will be appropriate and the program will be successfully installed. Near the end, it even tries changing the current working directory to that which is assumed to hold the package to be installed, and then runs several commands which build the program from source code.<br />
<br />
All in all, this script would probably work; it runs many standard popular repository programs and package managers, and runs the nearly-universal commands needed to build a program.<br />
<br />
One of the more subtle jokes in the comic is the inclusion of <code>apt-get</code> and <code>sudo apt-get</code> in the same script. In most cases this would be redundant as the <code>sudo</code> command is just to add admin permissions. This could be a reference to a joke in the Linux community about forgetting to include the sudo command. An example of this joke being used elsewhere was a [https://twitter.com/liamosaur/status/506975850596536320 viral tweet] that showed a workaround for the issue. Sudo has also been used both by [[Randall]] in [[149: Sandwich]] and by Bill Amend to force Randall to let him appear on xkcd with [[824: Guest Week: Bill Amend (FoxTrot)]].<br />
<br />
Another explanation for this could be that plain "apt-get" is for Debian, while Ubuntu etc. use sudo.<br />
<br />
The tool <code>curl</code> downloads files from the network (e.g., the Internet). Used like <code>curl http://xkcd.com/</code> it downloads the xkcd main page and displays the HTML source code. The pipe <code>|</code> in the script attaches the output of the command before the pipe to the input of the command after the pipe. Both commands are executed concurrently. <code>bash</code> is a popular shell for Unix-like operating systems. The line <code>curl "$1" | bash</code> tries to download a file from the network and to execute the download directly. <!--- Although this is a common practice for conveniently installing software, it is considered extremely insecure and should never be done. [ed. note: there's no reason this cannot be secure, especially if HTTPS with validated certificates is used, from a trusted domain which utilizes DNSSEC] --><br />
<br />
The use of & at the end of each line causes the shell interpreter to execute the commands in parallel (asynchronously) instead of sequentially. Even if single commands fail, the rest of them will be executed. Note this is even the case for the final commands which attempt to change to the installed package, probably the only reason why this may not work completely for packages that do need compiling after being downloaded. (However, just running this script again would probably do the trick.)<br />
<br />
There appears to be a bug with the & at the end of the "git clone" line; since a git repository typically contains program source code, not executables, it may have been intended to retrieve the source code with git and then compile and install the program in the next line. In this case, the single & should be replaced with &&, an operator that will run the second command only if the first one has completed successfully. This plays into a second bug on the "configure" line, where the placement of the & means that only the "make install" command will be run asynchronously after the "configure" and "make" steps have finished in sequence. To make success as likely as possible, the two lines should be like this:<br />
<br />
git clone <nowiki>https://github.com/</nowiki>"$1"/"$1" && (cd "$1"; ./configure; make; make install) &<br />
<br />
This bug could be indicative that Randall wanted to use && throughout the whole script. This would make the installation trying sequentially and the first successful install stops the script and will not install multiple versions of the same software.<br />
<br />
The title text mentions the possibility that the same program may be in multiple repositories, so in this case, the script will download and install several versions, or it may fail on a number of repositories, in which case usually nothing bad happens. Since all the commands come from different operating systems, versions, or distributions, it is not very likely that more than one will work (with the exception of pip/easy_install and the two forms of apt-get) or even exist on the same system. It mentions that adding a way of automatically saying "yes" to questions asked during the different repository-fetching programs' running, by making them read input from another program that writes a (nearly) endless stream of "y"s, could simplify things further. <code>2>/dev/null</code> redirects the second output stream (the "error stream") to the null device driver, which discards all writes to it.<br />
<br />
==Transcript==<br />
:[In the panel is a shell script which, unusual for xkcd, uses only lower case. At the top the title of the program is inlaid in the frame, which has been broken here.]<br />
:<big>Install.sh</big><br />
<br />
:<nowiki>#!/bin/bash</nowiki><br />
<br />
:pip install "$1" &<br />
:easy_install "$1" &<br />
:brew install "$1" &<br />
:npm install "$1" &<br />
:yum install "$1" & dnf install "$1" &<br />
:docker run "$1" &<br />
:pkg install "$1" &<br />
:apt-get install "$1" &<br />
:sudo apt-get install "$1" &<br />
:steamcmd +app_update "$1" validate &<br />
:git clone <nowiki>https://github.com/</nowiki>"$1"/"$1" &<br />
:cd "$1";./configure;make;make install &<br />
:curl "$1" | bash &<br />
<br />
==Trivia==<br />
*pip and easy install are package managers for Python<br />
*brew is the successor/replacement for MacPorts and a package manager for OS X<br />
*npm is the node package manager that maintains node.js packages<br />
*yum is the package management tool for Red Hat Enterprise Linux and some derivatives.<br />
*dnf is the package management tool for Fedora since version 22.<br />
*pkg is the package management tool on BSD systems<br />
*apt-get is the package management tool of choice on debian and derivatives (eg Ubuntu)<br />
*steamcmd refers to Steam, the computer game client<br />
*git is the revision control software used for eg. the linux kernel and gained a lot of traction through the github plattform<br />
*configure/make/make install refers to the default way of compiling software from source (on Linux/Unix)<br />
*curl is a tool for loading data via http:// (eg from a website), this data is then pushed to the shell interpreter (in order to install). <br />
**Note: While this is a security nightmare, the Nvidia drivers for Linux were (but no longer are) installed like that<br />
<br />
{{comic discussion}}<br />
<br />
[[Category:Programming]]</div>162.158.91.195https://www.explainxkcd.com/wiki/index.php?title=Talk:1618:_Cold_Medicine&diff=107262Talk:1618: Cold Medicine2015-12-19T00:29:30Z<p>162.158.91.195: </p>
<hr />
<div>How hard would it actually be to turn street drugs back into cold medicine? [[User:Benjaminikuta|Benjaminikuta]] ([[User talk:Benjaminikuta|talk]]) 05:41, 18 December 2015 (UTC)<br />
<br />
- I'm unsure on the actual scientific accuracy of this, given it is a fake paper, but http://heterodoxy.cc/meowdocs/pseudo/pseudosynth.pdf [[Special:Contributions/108.162.221.13|108.162.221.13]] 05:49, 18 December 2015 (UTC)<br />
<br />
This is in reference to recent studies that have proven that Phenylephrine is no worse than a placebo.<br />
https://en.wikipedia.org/wiki/Phenylephrine<br />
http://www.annallergy.org/article/S1081-1206(10)60240-2/abstract<br />
[[Special:Contributions/162.158.2.138|162.158.2.138]] 06:53, 18 December 2015 (UTC)<br />
<br />
- I keep hearing about this Placebo. It seems like a very potent medicine that is good for everything. Where can you buy it? {{unsigned ip|162.158.90.213}}<br />
:Just get anything that is labeled 'homeopathic'. --[[Special:Contributions/162.158.153.101|162.158.153.101]] 10:55, 18 December 2015 (UTC)<br />
<br />
:In more than 100 countries it is manufactured under the brand name {{w|Tic Tac}} and available even in supermarkets. -- [[User:Hkmaly|Hkmaly]] ([[User talk:Hkmaly|talk]]) 13:41, 18 December 2015 (UTC)<br />
<br />
-I don't know about the paper specifically, but by the principle of microscopic reversibility (https://en.wikipedia.org/wiki/Microscopic_reversibility), not only can you turn the products back into the reagents, you can do so using the exact same mechanisms. Chemical reactions are always going both ways, and they will tend towards the equilibrium from the higher concentration ~pure meth. That does not say anything about practicality, I am not versed in meth-synthesis, but maybe it involves a process with a product harder to acquire than pseudoerphine (maybe because it is useless and simply disposed of) which would be required as a reagent in this case. I don't know. [[Special:Contributions/162.158.91.195|162.158.91.195]] 00:29, 19 December 2015 (UTC)<br />
<br />
----<br />
<br />
I don't think it's suggesting turning meth back to medicine. I think it's a reference to heroin and at least a handful(?) of other now-illegal drugs originally introduced purely as medicinal products. [[User:Xseo|Xseo]] ([[User talk:Xseo|talk]]) 12:13, 18 December 2015 (UTC)<br />
:- i respectfully disagree, i reckon its exactly suggesting that ... Need cold medicine so bad i would buy illegal drugs made from cold medicine and seek to reverse the process. Obviously not the most practical way of getting cold medicine ... but thats the joke.[[User:Plm-qaz snr|Plm-qaz snr]] ([[User talk:Plm-qaz snr|talk]]) 13:08, 18 December 2015 (UTC)<br />
<br />
-----<br />
<br />
Codeine was originally a cough suppressant. It was and is the most effective and reliable cough medicine available and very safe in the usual quantities. You can't get it, though -- for an ordinary cough -- because some people like to use a lot of it for fun and sometimes get addicted to large quantities of it. You could synthesize it or an analogue of it from heroin or oxycodone about as safely as any kitchen chemistry because they share the same opium base. <br />
<br />
The principal cold medicines are cough suppressants (codeine is best -- other things work but much worse), decongestant (pseudoephedrine works great, phenylephrine is no more effective than a placebo), mild anti-inflammatories like ibuprofen, and antihistamines for anti-sneezing (there are many good ones based on Seldane like Claritin). Most people like to combine those at nighttime with a good mild tranquil sleep promoter -- I recommend whisky or rum. Note that pseudoephedrine is banned in some states of the USA such as Oregon. [[Special:Contributions/108.162.216.65|108.162.216.65]] 13:58, 18 December 2015 (UTC)<br />
<br />
-----<br />
<br />
I take the title text differently - that since buying pseudoephedrine-containing drugs legally in a larger than minimal quantity (e.g. to stockpile them at home to have them at hand when you need them) already makes you a criminal suspect with 100% certainty (because you have to show your ID), it may be safer to buy illegal drugs on the black market, where you have at least some chance of not being caught. As for turning meth back to PE - it is possible for sure, since all chemical processes are reversible in one way or another, but I am not versed enough in organic chemistry to say if it is easier or harder than the other way round. -- [[Special:Contributions/162.158.90.224|162.158.90.224]] 12:33, 18 December 2015 (UTC)<br />
:Burning is chemical process. Creating wood from ash is generally considered unpractical. -- [[User:Hkmaly|Hkmaly]] ([[User talk:Hkmaly|talk]]) 13:41, 18 December 2015 (UTC)<br />
:Yes, it is impractical. However, due to one of the fundamental principles of quantum mechanics being the fact that information can't be destroyed, only obfuscated, scatter, maybe even left out of reach, but never destroyed, all the information needed to turn the ash back into wood is still in the universe. All that is left to do is retrieve all that information and figure out a way by which everything can become uncombusted, and you have it turned back into wood. Sure, it would be easier to use the ash as fertilizer to help grow another tree, but it isn't impossible.[[User:Mulan15262|Mulan15262]] ([[User talk:Mulan15262|talk]]) 14:50, 18 December 2015 (UTC)<br />
<br />
-----<br />
<br />
Today I learned that you can make methamphetamine from Pseudoephedrine! [[Special:Contributions/188.114.106.173|188.114.106.173]] 18:34, 18 December 2015 (UTC)</div>162.158.91.195