Results 1 to 3 of 3

Thread: How to relaunch a bash script with all of the same inputs

  1. #1
    Join Date
    Oct 2018
    Beans
    2

    Lightbulb How to relaunch a bash script with all of the same inputs

    Is there a cleaner/easier way to do this?

    Code:
    #!/bin/bash
    updatesFound=0
    
    #
    ## Some code here to check for updates found remotely
    #
    
    if [ $updatesFound -gt 0 ]; then
        # the script running is outdated, and needs to be relaunched
        relaunchCMD="$0"
        i=1
        ARGC=$#
        while [ $i -le $ARGC ]; do
            relaunchCMD="$relaunchCMD \"${!i}\""
            i=$((i+1)); # increment input
        done
        $relaunchCMD --no-update
    fi
    Thanks!

  2. #2
    Join Date
    Nov 2008
    Location
    Woodstock, IL
    Beans
    30
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: How to relaunch a bash script with all of the same inputs

    Have you tried the following:

    Code:
    $0 "$@"
    to relaunch?
    Comfortably numb...

  3. #3
    Join Date
    Oct 2018
    Beans
    2

    Re: How to relaunch a bash script with all of the same inputs

    The works perfect, I thought there was something like that, but couldn't find a reference.

    Thanks!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •