Hacker News new | ask | show | jobs
by noisy_boy 778 days ago
A simple (not perfect) approach could be to have a comment containing a "unique" string on the last line and grep for it as the first check to ensure that the entire script has downloaded.

    #!/usr/bin/env bash
    
    set -u
    
    grep -wq '^# asfewdq42d3@asd$' $0
    [ $? -ne 0 ] \
        && echo "script is not complete - re-download" \
        && exit 1
    
    echo "script is complete"
    
    # asfewdq42d3@asd
1 comments

This doesn't work for something like `curl ... | sh`