dfinity / sdk

IC SDK: a Software Development Kit for creating and managing canister smart contracts on the ICP blockchain.
https://internetcomputer.org/developers
Apache License 2.0
174 stars 83 forks source link

If a user types CTL+C while the license acceptance prompt is displayed, then they should return to their original shell. #1356

Open p-shahi opened 3 years ago

p-shahi commented 3 years ago

While experimenting with the install script I hit a particularly strange bug:

When prompted to accept the license, if I hit CTRL-C to quit, I am not dropped back to my own shell; instead I am dropped into the shell the install instructions asked me to run as part of downloading and running the script.

In other words, in the command

$ sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

That initial sh command is still running after I kill the script.

This confuses me a lot for a bit.

I poke at the script for a bit to see if I can fix the problem, and one way to do it is with the trap shell command:

trap exit 2

Though it should probably do more cleanup than just exit. I note that rustup does not do this though, and I am not sure offhand why rustup’s handling of CTRL-C works correctly where Dfinity’s does not.

lwshang commented 3 years ago

This behavior happens on Linux (brson was using this OS). While it works properly on mac.

I did some experiments with the install script on Linux.

Other than the standard one line command, I separate it into two steps:

  1. Save the script as a sh file
    curl -fsSL https://sdk.dfinity.org/install.sh > dfx-installer.sh
  2. Run the script

    • Run directly will work perfectly, i.e. CTRL-C will get back to original shell

      sh dfx-installer.sh
    • Mimic the one-liner then it behaves as brson described.

      sh -ci "$(cat dfx-installer.sh)"