Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [set]

The tag has no usage guidance.

0
votes
0answers
18 views

How can I ensure some shell or bash option is enabled or disabled and later on restore it if I have changed it? [duplicate]

Sometimes I want to do something which requires some shell or bash option enabled or disabled. For example, https://unix.stackexchange.com/a/108520/674 So I could first change the shell or bash ...
1
vote
1answer
36 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 ...
0
votes
2answers
51 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? ...
0
votes
2answers
57 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. ...
0
votes
2answers
56 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 ...
0
votes
1answer
50 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 ...
0
votes
0answers
45 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 ...
3
votes
1answer
844 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 ...
0
votes
1answer
184 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 ...
-3
votes
1answer
3k 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....
4
votes
1answer
642 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, ...
2
votes
2answers
95 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 -...
1
vote
3answers
3k 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 ...
1
vote
1answer
91 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 ...
2
votes
2answers
2k 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 ...
28
votes
4answers
9k 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 "...
5
votes
4answers
4k 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@...
6
votes
1answer
2k 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, ...
13
votes
2answers
2k 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 ...
17
votes
2answers
1k 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 ...
2
votes
2answers
5k 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?
7
votes
4answers
1k 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.
3
votes
2answers
319 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 ...
4
votes
2answers
416 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 ...
27
votes
1answer
16k 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 ...
1
vote
1answer
728 views

Edit the editor in bash and other shells

Executing the fc builtin causes bash and other shells to fire up $FCEDIT on the last command. Because FCEDIT is a variable, this is inherently customizable. Is it possible to also customize the ...
0
votes
1answer
1k views

Difference between set variable “value” and set variable value?

What is the difference between the following 2 examples in a shell script: set variable1 "value" set variable2 value
0
votes
1answer
120 views

Dash print expanded commands

Running xtrace or set -x with Bash will print the expanded command: $ bash -xc 'touch "alfa bravo"' + touch 'alfa bravo' However Dash does not print the command that is actually run: $ dash -xc '...
15
votes
4answers
56k views

What does set command without arguments do?

What does set command without arguments do? As I can see it prints out my environment variables just like env command but in alphabetical order. And further it prints some different information (...
1
vote
3answers
219 views

How to undo typo `set -ovi`?

I wanted to execute set -o vi, but instead I did set -ovi. Now when I checking set -o I see extra weird options such as: $ set -o set -o ... update_terminal_cwd; and as result, update_terminal_cwd;...
0
votes
1answer
63 views

Setting arguments from a text file does not work

Here is my code. #!/bin/bash set -- $(cat /home/jeevan/tempzen1.txt) zenity "$@" file tempzen1.txt contains : --list --title FILE-SELECTOR --column serialno. --column file --width 1000 --...
1
vote
2answers
99 views

How do I test if my variable is not in a set?

I am trying to modify the bash shell script and need some assistance. I have a directory with a bunch of files. What I need is to go through the files in a loop and if the file name not in a specific ...
0
votes
1answer
14k views

Setting LD_LIBRARY_PATH

I am trying to run a program in a server with Linux Ubuntu 3.16.0-31-generic and it gives me the following error: error while loading shared libraries: libmpich.so.3: cannot open shared object file:...
2
votes
2answers
488 views

Where are the details of 'Pathname Expansion' and 'Brace Expansion' in man page? [closed]

I was trying to go through a man page with a calm mind for the first time, and I hit a frustration already 2 minutes down the road. $ man set nocaseglob If set, bash matches ...