aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/eval.fish
blob: aec8de27a9f9bc7a2c4b0b92ea795e893bc6089e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

function eval -S -d "Evaluate parameters as a command"

	# If we are in an interactive shell, eval should enable full
	# job control since it should behave like the real code was
	# executed.  If we don't do this, commands that expect to be
	# used interactively, like less, wont work using eval.

	set -l mode
	if status --is-interactive-job-control
		set mode interactive
	else
		if status --is-full-job-control
			set mode full
		else
			set mode none
		end
	end
	if status --is-interactive
		status --job-control full
	end

	echo begin\; $argv \;end eval2_inner \<\&3 3\<\&- | . 3<&0
	set -l res $status

	status --job-control $mode
	return $res
end