Improved PlatformIO CLI Install Script Reduces Copy-Paste Labour

Many software distributions come with pages of copy-paste commands that have errors or tedious missteps. I wrote a pio install script in August 2022 that worked but did not properly handle error conditions. So now I provide an improved script that has six self-documented functions replacing 3 or more pages of document reading and copy-pasting. There is only 1 command to type: “. get_pio.sh” which I tested on a Linux PC running Xubuntu 22.10. But it is generic and should work on any Linux PC with the Bash shell.
Having good documents is appreciated but anything scriptable should be scripted so that the non-scripted chores are not distributed to the user community.

# file: get_pio.sh
# Bash script to install PlatformIO on a Linux PC with Xubuntu 23.10
# This script is easier than copy-pasting from on-line documents.
# It requires Python3, curl, wget, sudo
# Type ". get_pio.sh" to run it. Note the 'dot' preceding the file name
# activates the Bash interpreter.

# There are six steps to complete the task . It aborts if some command
# returns an error and reports the last step completed. Fix it, and
# try again

# ------------------------------------------
step1 ()
{
   echo "..."
   echo "step1: ..remove old pio files to avoid conflicts"
   rm -vf ~/.local/bin/pio  && \
   rm -vf ~/.local/bin/piodebuggdb  && \
   rm -vf ~/.local/bin/platformio && \
   rm -rf ~/.platformio
}

# ------------------------------------------
step2 ()
{ 
  echo "..."
  echo "step2: ..get the python platform script from github"
  wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py
}

# ------------------------------------------
step3 ()
{ 
  echo "..."
  echo "step3: create a virtual environment"
  python3 get-platformio.py
}

# ------------------------------------------
step4 ()
{
    echo "..."
    echo "step4: update the udev rules"
    curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/master/scripts/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules && \
      sudo service udev restart
}

# ------------------------------------------
step5 ()
{
    echo "..."
    echo "step5: setup pio execution links"
    mkdir -p ~/.local/bin && \
    ln -s ~/.platformio/penv/bin/platformio  ~/.local/bin/platformio && \
    ln -s ~/.platformio/penv/bin/pio         ~/.local/bin/pio && \
    ln -s ~/.platformio/penv/bin/piodebuggdb ~/.local/bin/piodebuggdb
}

# ------------------------------------------
step6 ()
{
    echo "..."
    echo "step 6: user joins the serial port group"
    sudo usermod -a -G dialout $USER
    echo "If error, then fix it and try again. Else ..."
    echo "Logout and Login again to use new profile"
}

echo "...This command list should complete the PlatformIO installation"
step1 && \
step2 && \
step3 && \
step4 && \
step5 &&
step6