The dot (.) or source command is used to evaluate shell scripts in the current execution context
Questions tagged [dot-source]
35 questions
1
vote
2 answers
What does this notation mean in bash?
I am pretty sure this will be a duplicate, because I have seen it sometimes at other places, but I do not remember where and I also (obviously) do not know how it is called.
In an other SO post, there is this piece of code (bash):
obj(){
. <(sed…

Itération 122442
- 2,644
- 2
- 27
- 73
1
vote
2 answers
bash, how to dot source a downloaded file (using curl) into bash
I have .sh file that I would like to dotsource into my running environment. This does not work:
curl -s https://raw.githubusercontent.com/bla/bla/master/stuff.sh | bash
The above does not work, i.e. The script runs, but the environment variables…

YorSubs
- 3,194
- 7
- 37
- 60
1
vote
0 answers
Bash : Dot-Command Double Trouble
if i use the dot-command from bash (or "source" ) it executes TWICE
===== demo === ( for import ) ====== (saved as "demo")
x+="|"
subResTest() {
return 0 # do nothing
}
echo "HI"$x
====== test ==== ( same directory as demo )
#/bin/bash
.…

Christian Schell
- 21
- 2
1
vote
3 answers
Is it possible to dot source a string variable in PowerShell?
I know I can dot source a file:
. .\MyFunctions.ps1
But, I would like to dot source the commands in a string variable:
. $myFuctions
I see that this is possible:
.{$x=2}
And $x equals 2 after the script block is sourced.
But... .{$myFunctions}…

Joe B
- 692
- 8
- 18
1
vote
1 answer
How Do I Dot Source Functions Within a Subfolder in PowerShell
I am attempting to create a PowerShell Module that will dot-source any functions found with the subfolder "\Functions" using the following code:
# Get the path to the function files
$functionPath = $PSScriptRoot + "\Functions\"
# Get a list of all…

Kismet Agbasi
- 557
- 2
- 8
- 28
1
vote
1 answer
Dot-source file from different locations
I'm dot-sourcing a "function library" file into every Powershell script I'm working on.
Currently, I'm putting this file in the same directory as the script and dot-sourcing it as follows:
. (Join-Path $PSScriptRoot FunctionLibrary.ps1)
This is…

turbonerd
- 1,234
- 4
- 27
- 63
1
vote
1 answer
Source command in bash script
I am trying to put a source command in a bash script so that I can quickly set up and use a virtual environment when writing django websites.
I tried the following without much success as my path was not prefixed with the (path) like it does when I…

Stephen Brown
- 564
- 1
- 9
- 23
0
votes
1 answer
Setting a static member from dot-sourced file
While getting the value of a static member from inside a dot-sourced ps1 file always works, setting a static member seems inconsistent.
test.ps1:
class A
{
static $val
A()
{
[A]::val = "empty"
}
}
$A = [A]::new()
write-host…

SnoopTheDog
- 1
- 2
0
votes
2 answers
Splitting a large PowerShell script using dot-source does not work
I have written a very large script that does different parts of a larger process.
Now I wanted to seperate these parts to different scripts so I moved each part of the logic to a different ps1 files.
I created:
Basic_Functions.ps1 > this contains…

Duffkess
- 38
- 6
0
votes
1 answer
Powershell Try Catch which stops when external script fails
I have several powershell scripts that I am running from one powershell scripts.
I am using a try-catch to stop on errors. But that doesn't work with external scripts I'm calling. I cant use dot-source because some of the scripts require the 32 bit…

moore1emu
- 476
- 8
- 27
0
votes
0 answers
How to invoke a function defined in another Powershell script within a Workflow?
Usually, I use dot-sourcing to "import" my function defined in other script files.
But the Powershell Workflow does not allow dot-sourcing, and it can't recognize functions defined out of scope.
Is there any possible way instead of copy-pasting all…

David Lee
- 1
- 1
0
votes
1 answer
Does the dot command behave uniformly across different shells?
You can use the . command to execute commands from a shell script as if they were in the calling shell script itself.
If I use the dot command in my shell scripts, will it behave similarly across different shell interpreters?
PLEASE Note: I'm not…

Elifarley
- 1,310
- 3
- 16
- 23
0
votes
0 answers
Using invoke command gives dot sourcing error
I'm trying to access a remote computer using Invoke-Command but I keep getting the following error:
Cannot dot-source this command because it was defined in a different language mode. To invoke this command without importing its contents, omit the…

pesky_programmer
- 131
- 3
- 12
0
votes
0 answers
Dot Source with Join-Path
Is it possible to dot source a path with join-path?
Example
With MASTER.ps1 I invoke CHILD.ps1
MASTER Lives in C:\Folder
CHILD Lives in C:\Folder\Sub
MASTER.ps1
$FooBar = 'Cheese'
"C:\Folder\Sub\CHILD.ps1 " | Invoke-Expression
CHILD.PS1
.…

arealhobo
- 447
- 1
- 6
- 17
0
votes
1 answer
using the unix command "source" in ansible
I have the following ansible playbooks:
runWithDotSlash.yml
---
- hosts: user@myhost.local
tasks:
- name: try running a script with dot slash
command: ./script.sh
runWithSource.yml
---
- hosts: user@myhost.local
tasks:
- name:…

user11466558
- 127
- 3
- 10