Results 1 to 2 of 2

Thread: Illegal option -f in my shell script

  1. #1
    Join Date
    Dec 2013
    Beans
    1

    Illegal option -f in my shell script

    Hi

    I get this error: "
    Illegal option -f" in my shell script
    only when I run with watch command: watch -n 4 ./collect-results.sh

    When I use only ./collect-results.sh works fine

    Any ideas?

    Code:
    #/bin/bash
    ...
    
    
    export -f get_data
    export -f get_jitter
    export -f get_average_throughput
    export -f get_total_latency
    export -f get_maximum_latency
    
    


    Thanks

  2. #2
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Illegal option -f in my shell script

    Hello and welcome to the forum

    I suspect it's because watch is running the command in a dash shell - overriding your #!/bin/bash shebang - from the watch manpage

    Code:
    NOTE
           Note that command is given to "sh -c" which means that you may need to
           use extra quoting to get the desired effect.  You can disable this with
           the -x or --exec option, which passes the command to exec(2) instead.
    (in Ubuntu, /bin/sh is a symlink to /bin/dash by default). There doesn't seem to be an explicit option to tell it to use bash - if it's essential to make this work, you could always modify the symlink (I've done that myself, for things that really won't work otherwise - e.g. Makefiles that assume /bin/sh is a bash shell).

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
  •