Skip to main content

Questions tagged [set]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
2 answers
60 views

set -o xtrace for just one line? [duplicate]

bash 4.4.20(1) on RHEL 8.4. set -x ; ./blarge ; set +x works, of course, but it's just that much more stuff to remember to remove when you're finished. And gets sticky if you're running ssh, sudo, ...
RonJohn's user avatar
  • 1,144
0 votes
1 answer
35 views

How to unset SHELLOPTS monitor:notify?

I like getting notified immediately when a background process exits. To do that one uses: $ set -b When you do that, it sets the shell option, contained in the BUILTIN variable SHELLOPTS, called &...
Richard T's user avatar
  • 224
0 votes
0 answers
21 views

What does "set -- command doas $@" do in my Bash function? [duplicate]

I use this Bash oneliner, set -o errexit;set -o pipefail;set -o nounset;doas() { [[ "${EUID}" == '0' ]]||set -- command doas "${@}";"${@}";} in the head of my scripts in ...
John Smith's user avatar
2 votes
1 answer
245 views

Using set -e (errexit) with block of commands and executing another on fail of that block (SC2181)

I just found out about set -e as I was searching for an answer to "how to run many commands (without &&) and immediately stop on non-zero exit code of any of them?". The set -e was ...
Andrew15_5's user avatar
2 votes
1 answer
484 views

nftables Named Set Update Delay

I have the following in nftables.conf: table inet nat { set blocked { type ipv4_addr } chain postrouting { type nat hook postrouting priority ...
Synthetic Ascension's user avatar
1 vote
1 answer
3k views

Ansible: set_fact after successful variable match in array

I have following playbook ~ # cat demo.yml: - name: demo hosts: localhost gather_facts: no vars: set: task: type: var1 task: - type: var1 - type: var2 - type: ...
Rafal Niznik's user avatar
0 votes
2 answers
126 views

Avoid printing of 'tee' trace line

I have the following in a script: #!/bin/bash logFile='script.log' echo -n > $logFile log="tee -a $logFile" set -x scp ... user@host:... ssh user@host " echo '...message...' &...
Gerold Broser's user avatar
2 votes
2 answers
13k views

Handling long-options with getopts

I am parsing options with getopts but would like to handle long-options as well. print-args () { title="$1" ; shift printf "\n%s\n" "${title}: \$@:" for arg in "$@...
Vera's user avatar
  • 1
2 votes
1 answer
825 views

Difference between "IGNOREEOF=n" variable and "ignoreeof=n" word usage?

When i use ignoreeof of set builtin, i realized "IGNOREEOF=n" variable and "ignoreeof=n" word can usable for limitation. For example; └─$ bash └─$ set -o ignoreeof └─$ IGNOREEOF=2 └...
testter's user avatar
  • 1,470
0 votes
1 answer
632 views

What is the differences of outputs from set -o and set +o

When I use set -o: ❯ set -o noaliases off aliasfuncdef off allexport off noalwayslastprompt off alwaystoend on appendcreate off noappendhistory ...
shin's user avatar
  • 759
1 vote
0 answers
156 views

`set -e` doesn't abort the script when a sub-shell fails as part of `export` [duplicate]

When running the following script: #!/bin/bash set -e export X=$(false) echo That did not abort X=$(false) echo That did abort It outputs: That did not abort So export X= doesn't abort the execution,...
dragonroot's user avatar
1 vote
1 answer
1k views

"interactive-comments" option usage for Bash script

I am wondering if it is possible to turn off the comment feature in noninteractive bash script. Turning on or off "interactive_comments" or "interactive-comments" with set or shopt ...
testter's user avatar
  • 1,470
4 votes
1 answer
1k views

Bash Shell “noexec” Option Usage Purpose

-n noexec ; Read commands and check syntax but do not execute them. Can you give an example of when we will need "noexec" which is one of the Bash options? Can someone give me an example of ...
testter's user avatar
  • 1,470
8 votes
3 answers
8k views

`set -x` debugging my `.zshrc`

When I use set -x to debug a command it output some extra lines. % set -x +precmd_update_git_vars:1> [ -n '' ']' +precmd_update_git_vars:1> [ '!' -n '' ']' +precmd_update_git_vars:2> ...
Ahmad Ismail's user avatar
  • 2,738
3 votes
1 answer
182 views

Bash Shell "onecmd" Option Usage Purpose [duplicate]

I read on man page, but I don't understand the purpose of bash's onecmd option. If I use the set -o onecmd command, the shell immediately exits. My expectation is for it to wait for me to enter one ...
testter's user avatar
  • 1,470
0 votes
1 answer
950 views

Curly braces disappear when trying to store a command into a variable

I wanted to print a command after some manipulation and store it into another variable for further usage. The usage is something like this: source new.sh tmp Content of new.sh: #!/bin/sh set a = ...
Anurag Mishra's user avatar
1 vote
1 answer
2k views

how do I allow clobber in unix

I am in the bash shell, BSD unix, under macos, but I think this would apply to many other unix shells. The noclobber option can be useful at times: > find . -name z > set -o noclobber > echo ...
Jacob Wegelin's user avatar
0 votes
1 answer
347 views

man set is not found in bash? [duplicate]

I am using bash I wanted to read the documentation of set But when i typed man set,it is showing No manual entry for set But when i code set hit="COVID19" echo $1 it prints as hit=COVID19 ...
Praveen Kumar-M's user avatar
0 votes
3 answers
254 views

What's up with set -x on my system?

In trying to learn about bash shell expansion and the effects that it has on passing arguments to grep, someone recommended that I use set -x to set the trace option on my shell and see how the shell ...
dbates's user avatar
  • 111
0 votes
0 answers
31 views

Meaning of -- in set command in shell script [duplicate]

What is the meaning of set -- $PATH in shell script? Is this the same as set echo "$PATH" ? What is the significance of -- here?
Esha's user avatar
  • 193
4 votes
2 answers
11k views

About listing bash options on `set`

When we print the console settings with the echo $- command, we output himBHs by default. However, when we run the same command in any script file, we only output hB. root@root:~# echo $- himBHs root@...
testter's user avatar
  • 1,470
10 votes
3 answers
14k views

What is `set -o keyword` doing on bash?

What function exactly is the "keyword" option assigned by the set command on bash shell? OPTION: set -o keyword OR set -k A simple example is enough for me to understand.
testter's user avatar
  • 1,470
3 votes
1 answer
1k views

Tracing (set -x) in a subshell

The builtin expression set -x turns on tracing, which prints each command after globbing but before execution. What I'm curious about is the difference of output set -x provides in different contexts. ...
Jon Anderson's user avatar
1 vote
1 answer
4k views

batch curl request w/ https address txt file

I have multiple phones I am trying to obtain the up time for phones. I have enabled REST API for all phones and am looking to run CURL scripts to get the value of uptime. I have a script to get the ...
mdbrown's user avatar
  • 11
1 vote
1 answer
428 views

set -u finds unset value in heredoc in bash script [duplicate]

I have a script that I've simplified here: #!/bin/bash # test.sh set -u ### test-script ### cat <<SCRIPT > ~/test-file-output #!/bin/bash set -e usage() { cat <<EOF Does a thing ...
Wimateeka's user avatar
  • 1,015
1 vote
0 answers
236 views

Output defined variables in current session

In the terminal I define the following variable: TEST_MY_VAR="something" echo $TEST_MY_VAR # output: something I expect this to be added to my current session. If I open a new terminal and try to ...
Remi's user avatar
  • 111
1 vote
1 answer
72 views

What is the reason to call a program with set -- env

I've seen that some code in bash scripts calls a programm with set -- env preceding actual command, e.g.: set -- env GOPATH=/some/path go build ${PACKAGE} what is the reason to do it? Isn't it the ...
g4s8's user avatar
  • 498
0 votes
2 answers
330 views

What does the -l argument mean in tcsh?

I'm running a tcsh shell. I have questions about the -l option in set -l. When I look at man for the set command, I don't see the -l argument. When using tcsh shell, what does the -l argument mean? ...
user3731622's user avatar
2 votes
2 answers
2k views

set -f inside function

I have a directory with files file1.c, file2.c and file3.c. The command find outputs: $find -name "*.c" ./file1.c ./file2.c ./file3.c Then I would like to use find without the quotes around .*c. ...
builder-7000's user avatar
0 votes
2 answers
246 views

bash & using a variable to decide when to use 'set'? [closed]

Looking to ascertain why when I do something like; [ ${debug:=0} -gt 0 ] && set -x || set +x regardless of the conditional set -x is enabled. The issue is that I am unable to use ${debug} to ...
jas-'s user avatar
  • 868
0 votes
1 answer
247 views

Having trouble changing character set in terminal

The GNU/Linux terminal doesn't display Swedish characters (sv_SE.UTF-8). I've googled, and found several sources with various solutions. To summarize the error, no matter what guide I follow, is ...
Paolo's user avatar
  • 209
0 votes
0 answers
73 views

Variable assignment exit status

Normally, if has an exit status not zero, execution will continue: false echo 'this will show' If you use set -e, the shell immediately shall exit: set -e false echo 'this will not show' I am ...
Zombo's user avatar
  • 1
4 votes
1 answer
3k views

Formatting display of of `set -v` output

From the description of set in the bash man page: -v Print shell input lines as they are read. Thus, the following example script: #!/usr/bin/env bash # setv.sh set -v foo=bar echo $foo ...
mbigras's user avatar
  • 3,170
0 votes
1 answer
2k views

Setting time with clock_settime without having root access

I have written a C program that syncs the time with the time from a GPS reciever. The computer is running Ubuntu 16.04 LTS. The program uses clock_settime(CLOCK_REALTIME, &timespec) to set the ...
Morten Skovgaard's user avatar
-1 votes
1 answer
19k views

How to set multiple env variables? [closed]

I have to set 10 env variables (setenv). I saved all these env variable in a filename.env. Is there a way to set all the variable inside the file with single command ? I tried with "source filename....
tollin jose's user avatar
4 votes
2 answers
1k views

Why does this compound command {...} not exit on error, when used with ||?

I'm trying to run this script: #!/bin/bash -e { echo "Doing something"; will_fail # like `false` echo "Worked"; } || echo "Failed" To my surprise, will_fail failed, ...
Minix's user avatar
  • 5,925
4 votes
2 answers
2k views

Preventing shell from exiting when set -e is turned on?

I have set -e turned on for my script. The only thing is there is one command here that I don't want causing the script to exit if it fails, but I want everything else to do that. How can I keep set -...
ZeroPhase's user avatar
  • 383
1 vote
3 answers
6k views

what does set -g means in config files?

In one of my config [~/.tmux.conf] there is a line : set -g default-terminal "screen-256color" set -s escape-time 10 I think it sets global variables of my system. But I am not sure.. I searched for ...
alamin's user avatar
  • 425
1 vote
1 answer
425 views

bash throws "set-ena" when I press/write b in the terminal

I have an extremely weird error: when I write the letter b in my terminal, bash immediately starts to write/throw endless stream of "set-enaset-enaset-enaset-enaset-enaset-ena..." until I force it to ...
Niteraleph's user avatar
2 votes
2 answers
7k views

Get rid of "connection refused" error in bash script

I have this line: exec 3<>/dev/tcp/127.0.0.1/9091 > /dev/null 2>&1 || { PORT_IS_FREE="yes"; }; which is checking if port 9091 is available. If a connection cannot be made, then I ...
Alexander Mills's user avatar
37 votes
4 answers
20k views

What is the meaning of "_="?

After I run the set -a var=99, I can find a sentence in the output of set: ... TERM=xterm UID=0 USER=root VIRTUAL_ENV_DISABLE_PROMPT=1 _=var=99 colors=/etc/DIR_COLORS ... Could anyone tell me what "...
yode's user avatar
  • 1,047
9 votes
4 answers
9k views

Can I unset the $1 variable?

Is it possible to unset the $1 variable? If not, I can't find out where it is explained in man. [root@centos2 ~]# set bon jour [root@centos2 ~]# echo $1$2 bonjour [root@centos2 ~]# unset $1 [root@...
timothepoznanski's user avatar
9 votes
1 answer
6k views

What is the parameter "i" of the set command in the bash shell?

I looked up the shell builtin command set by typing help set, and the short syntax description shows: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...] The help-documentation explains, ...
sharkant's user avatar
  • 3,750
18 votes
2 answers
6k views

What is "( set -o posix ; set ) | less " doing? [duplicate]

On my search for a command to list all shell variables, I somehow realized, that there is a command to list all environment variables, but somehow there is no one to list all shell variables, for ...
sharkant's user avatar
  • 3,750
20 votes
2 answers
5k views

Suppress the bash execution trace (set -x) from the outside of the script

I tried finding an answer to this question, but got no luck so far: I have a script that runs some other scripts, and many of those other scripts have "set -x" in them, which makes them print every ...
human's user avatar
  • 323
8 votes
2 answers
13k views

What does "set -f" in Korn Shell do?

In the book "A guide to aix 3.2", it says that one may use the Korn Shell command set -f to "disable filename generation", but what does it mean? What happens with set -f?
elbarna's user avatar
  • 12.8k
8 votes
4 answers
2k views

How to remove the functions displayed by set command? [duplicate]

When set command is used without any options, it displays the names and values of all shell variables and functions. We want to display only the variables and avoid the functions from the output.
frp farhan's user avatar
4 votes
2 answers
1k views

Bash -v test doesn't work with associative arrays in 4.3.46

The -v unary operator that was introduced in version 4.2 to test if a variable is set or not does not appear to work in bash 4.3.46 on associative arrays. I have some bash test code that I run ...
krb686's user avatar
  • 559
5 votes
2 answers
1k views

Redirect a portion of a bash script to a file to capture set -x output

I have a bash script and I want to capture a portion of the script with a set -x and redirect that output to a file. I can see what the ENVFILE is setting but its going to std out. Is there a way ...
Shar Hunter's user avatar
99 votes
2 answers
63k views

What does "set --" do in this Dockerfile entrypoint?

I'm trying to understand what this Docker entrypoint does. It seems to me that's a very common pattern when writing Dockerfiles, but my bash skills are limited and I have no idea of all the special ...
Lucas Pottersky's user avatar