source command not found in sh shell

前端 未结 12 707
温柔的废话
温柔的废话 2020-11-28 02:14

I have a script that uses sh shell. I get an error in the line that uses the source command. It seems source is not included in my

相关标签:
12条回答
  • 2020-11-28 03:00

    This problem happens because jenkins Execute Shell runs the script via its /bin/sh

    Consequently, /bin/sh does not know "source"

    You just need to add the below line at the top of your Execute Shell in jenkins

    #!/bin/bash
    
    0 讨论(0)
  • 2020-11-28 03:04
    $ls -l `which sh`
    /bin/sh -> dash
    
    $sudo dpkg-reconfigure dash #Select "no" when you're asked
    [...]
    
    $ls -l `which sh`
    /bin/sh -> bash
    

    Then it will be OK

    0 讨论(0)
  • 2020-11-28 03:06

    I found in a gnu Makefile on Ubuntu, (where /bin/sh -> bash)

    I needed to use the . command, as well as specify the target script with a ./ prefix (see example below)

    source did not work in this instance, not sure why since it should be calling /bin/bash..

    My SHELL environment variable is also set to /bin/bash

    test:
        $(shell . ./my_script)
    

    Note this sample does not include the tab character; had to format for stack exchange.

    0 讨论(0)
  • 2020-11-28 03:08

    On Ubuntu, instead of using sh scriptname.sh to run the file, I've used . scriptname.sh and it worked! The first line of my file contains: #!/bin/bash

    use this command to run the script

    .name_of_script.sh
    
    0 讨论(0)
  • 2020-11-28 03:10

    In Bourne shell(sh), use the . command to source a file

    . filename
    
    0 讨论(0)
  • 2020-11-28 03:10

    This may help you, I was getting this error because I was trying to reload my .profile with the command . .profile and it had a syntax error

    0 讨论(0)
提交回复
热议问题