POSIX is an acronym for "Portable Operating System Interface", a family of standards specified by the IEEE for maintaining compatibility between operating systems.

learn more… | top users | synonyms

1
vote
0answers
20 views

POSIX compliant shell script not portable because of the tools used inside [on hold]

I've written a script which runs in a strictly POSIX compliant shell without trouble on my machine but a buddy of mine couldn't execute it. It seems as if his machine has different versions of tools ...
-2
votes
1answer
25 views

Regular expression in unzip files argument not working

I'm trying to view the contents of a zip archive using an extremely simple regular expression. This works: rmorton@Rockette:~$ unzip -l Downloads/WeiDU-Linux-236.zip "*/i386/tolower" "*/i386/weidu" ...
29
votes
7answers
2k views

Is test or [ or [[ more portable both between bash shells and between other shells?

I see I can do $ [ -w /home/durrantm ] && echo "writable" writable or $ test -w /home/durrantm && echo "writable" writable or $ [[ -w /home/durrantm ]] && echo ...
1
vote
1answer
27 views

open() return new file descriptor posix [closed]

I have to set the return values for open() in posix. How do I return "the new file descriptor" as it is said in the Linux man pages: RETURN VALUE open(), openat(), and creat() return the new ...
2
votes
2answers
73 views

Is there a specific reason why iptables would return an exit code of 3 (instead of 1?) when executed without sufficient privileges?

I simply forgot to use sudo: usr@arch ~[0] $ iptables -L iptables v1.4.21: can't initialize iptables table `filter': Permission denied (you must be root) Perhaps iptables or your kernel needs to be ...
3
votes
2answers
41 views

How is it possible to execute a command with an unknown number of arguments in a POSIX shell?

I want to search for multiple words inside the current directory. To accomplish this I use something like this. grep -e "word1" -e "word2" -R . This works fine. Taking this one step further, I ...
2
votes
1answer
50 views

Single or double brackets and portability

I have found some very good answers here on the differences between [ and [[ in 'if' statements. For specific named shells, it seems to be a good idea to use [[ over [ (and it is faster, too). I'm ...
3
votes
1answer
96 views

Consequences of setting up POSIX locales

Small background of the situation: We are using several UBUNTU servers having English as working language; however having en_US locale set in machines we encounter problems with apt-cacher-ng ...
2
votes
1answer
56 views

Process IDs range

On GNU/Linux system I seen only positive PIDs, but when kernel panic occured I seen info about process with PID=0. What's it? On Minix 3 I seen processes with negative PIDs. Minix is POSIX-compatible ...
7
votes
0answers
220 views

regarding portable sed -e… d b or ! b?

In this edit Stéphane Chazelas POSIXifies (again) my sed formatting by inserting an -expression break and another -expression statement. Now, I might just ask him why in the comments, I suppose, but ...
20
votes
1answer
419 views

When and how was the double-dash (--) introduced as an end of options delimiter in Unix/Linux?

I don't think the shell/utilities in historical Unix nor in something as "recent" as 4.4BSD supported using a double-dash(or two consecutive hyphens) as an end of options delimiter. With FreeBSD, you ...
3
votes
3answers
177 views

Interactive command usage reference: do you generally have that on Unix?

The question of why some commands rely on manpages whereas others rely on something like the --help flag for providing command usage reference is not new. There is usually a difference in scope ...
5
votes
1answer
133 views

Does Posix require any devices?

Does Posix require any devices? For example, /dev/urandom, /dev/zero or /dev/null? I suspect not because of non-*nix OSes, but wanted to ask for completeness.
2
votes
1answer
389 views

Removing non-printable characters using POSIX sed

Files created with roff and other "old-school" tools (for example man pages on many Unix systems) generate bold and underlined text in minimalistic terminals using tricks involving non-printable ASCII ...
7
votes
3answers
308 views

`/proc/$PID/cwd` : is there a POSIX equivalent?

Linux has a /proc directory and file‑system, which as far as I can tell, is not part of POSIX. In each /proc/$PID subdirectories, is a symbolic link, cwd, pointing to the actual working directory of ...
2
votes
1answer
555 views

How do I use grep to find a text string in files in sub folders of a parent folder without -r switch

I'm using Solaris 10 and have two grep versions one in /usr/bin and one in /usr/xpg4/bin. I have been searching for an answer on how to search for text within files within sub folders of a parent ...
24
votes
7answers
2k views

What's the difference of the Userland vs the Kernel?

I am trying to understand exactly what is userland? everyone that I ask says: "Anything that is not kernel". but it is not tangible for me. When I am reading that kernel can run that driver on the ...
3
votes
4answers
129 views

Protected environment variables?

Are there names of environment variables that cannot be overwritten by the user/a call to setenv? As I understand from POSIX1.2008, any process may edit the environment block, but must avoid ...
17
votes
2answers
397 views

explanation on chown(1) POSIX spec

The POSIX spec for the chown utility mentions in its rationale section about the chown user:group syntax (formerly chown user.group) (emphasis mine): The 4.3 BSD method of specifying both owner ...
5
votes
2answers
187 views

How exactly does `if $cmd ; then $cmd ; fi` differ from `$cmd && $cmd`?

In an answer to another very good question I made the following assertion: According to my reading of the POSIX specs, the use of one or the other makes no difference from a parsing standpoint. ...
1
vote
1answer
66 views

bash completion on posix mode

I would like to use an interactive posix bash shell but the autocompletion feature doesn't work. When i type the tab character it simply prints a tab. The tab completion only works when i'm on a non ...
0
votes
1answer
121 views

bash completion on posix mode [duplicate]

I would like to use an interactive posix bash shell but the autocompletion feature doesn't work. When i type the tab character it simply prints a tab. The tab completion only works when i'm on a non ...
5
votes
1answer
197 views

Where is $_ defined by POSIX?

In the comments to the accepted answer to this Unix & Linux StackExchange question, it is stated that $_ is "one of only some 7 special parameters defined by POSIX". I can't find that definition ...
10
votes
2answers
900 views

Is it OK to use “.” to run files instead of source - in .bashrc in Ubuntu and OS X?

OK, so source runs the script in the current shell and . separately, as detailed in running script with ". " and with "source " for example, but, specifically, in my .bashrc file, ...
2
votes
2answers
288 views

Is the double dash still the posix standard for long switches?

I've read several question about double dash: Single dashes - for single-character options, but double dashes -- for words? What does -- (double-dash) mean? (also known as “bare double dash”) ...
9
votes
5answers
1k views

What is meant by “a system call” if not the implementation in the programing language?

I would like to understand the term "system call". I am familiar that system calls are used to get kernel services from a userspace application. The part i need clarification with is the difference ...
5
votes
2answers
251 views

Which is the most portable of sed, awk, perl and sh?

Can someone put these tools in order of portability? Which of these is certain to be found on even the most minimal *nix systems? Is any of them 100% sure to be present? My guess is that the order is ...
5
votes
3answers
387 views

Are there “esoteric” (weird) but standards-compliant C compilers or runtimes?

As we know, the C standard does not specify a lot of details of the implementation, for example value of NULL pointer, order of bits and bytes (endiannes), alignment in structs and of stack ...
22
votes
4answers
1k views

Is the shell permitted to optimize out useless terminating commands?

If a shell is asked to perform a probably useless (or partially useless) command known to terminate, such as cat hugeregularfile.txt > /dev/null, can it skip that command's execution (or execute a ...
1
vote
1answer
329 views

Plain vi (not vim): Can't delete a line in insert mode: Is this behavior required by POSIX?

In the non-vim implementations of vi I've worked with, it's not possible to delete a line while in insert mode. vim does allows it—but it's my understanding that vim is not POSIX-compliant in ...
2
votes
1answer
345 views

Awk regular expression syntax with number of repetition - different handling between gawk 3 and gawk 4

I am having trouble understanding or explaining why the following expression fails in gawk 3.1.x and yet works in gawk 4.1.x: (Minimum working example) echo ";#ADCDE#" | awk '/#.{5}#$/' -> produces ...
0
votes
2answers
107 views

What does the `set $variable` do?

I know that set is used to manipulate environment variables, but I want to make myself sure - these alterations are not permanent, right? I mean once I close shell and reopen it, no changes will be ...
3
votes
1answer
238 views

Using shell's read command with live editing functionality (readline like)

Is there a standard (POSIX) way of asking the user some data from within a shell script, with read for example, while allowing live edition of the text being typed (what readline does)? I know bash ...
2
votes
1answer
121 views

indirect variable expansion in POSIX as done in bash? [closed]

Is it possible, or is there some elegant hack to do indirect variable expansion in POSIX as can be done in Bash? For context, I'm trying to do the following: for key in ${!map_*} do # do ...
2
votes
2answers
54 views

How can we obtain a temporary filename in a standard-conforming IEEE 1003.1 script?

How can we obtain a temporary file name in a standard-conforming shell script (using no commands or extensions which are not described the 2013 edition of IEEE 1003.1). There doesn't appear to be any ...
1
vote
1answer
212 views

Is the Linux implementation of the system configuration “variable” ARG_MAX different from other system variables and is it POSIX compliant?

In the shell, as explained in this this Q&A in the context of expansion, depending on the system, the maximum length of a command's argument is initially constrained by the kernel setup. The ...
1
vote
1answer
723 views

Reverse id command, I want the User/Group Name from the uid or gid

I know some uid and gids that I dont know who they belong to and they are not in /etc/passwd (could be LDAP or from another system). How do I get Id info from only uid or gid preferably without using ...
1
vote
2answers
34 views

Can I use `type` to check whether an arbitrary name is a valid command name?

The bash built-in type can be used for this purpose by checking its exit status: Exit Status: Returns success if all of the NAMEs are found; fails if any are not found. How portable is it? The ...
3
votes
1answer
72 views

Common flag designations and standards for shell scripts and functions

I have been adjusting to using GETOPT and GETOPTS in my shell scripts and custom functions to enable me to use the functions that I create more flexibly. After using a number of UNIX functions I have ...
2
votes
1answer
122 views

Are “mostly POSIX-compliant” systems still considered POSIX systems?

Irix and OS X are POSIX systems because they are fully-POSIX-compliant. However, operating systems like FreeBSD, Haiku, and GNU/Linux, for example, are "mostly-POSIX-compliant". Can people still ...
5
votes
2answers
101 views

Nested POSIX groups in Linux [duplicate]

If I want to add all of the members who belong to the supplemental group web_users to the apache group (as an additional supplemental group) can I just add web_users group to the apache group? Or do ...
8
votes
3answers
207 views

POSIX compliant way to work with a list of filenames possibly with whitespace

I have seen Bash scripting guides suggesting the use of array for working with filenames containing whitespace. DashAsBinSh however suggests that arrays are not portable so I am looking for a POSIX ...
4
votes
3answers
313 views

OS X/Linux one-liner/script to find the largest recurring group of lines in a text file?

I have a log containing an execution trace where there is infinite recursion eventually terminating when the stack is too deep. There are enough lines and valid included recursion within the larger ...
5
votes
4answers
129 views

Is it shell portable to run a command on the same line after variable assignment?

Is there any standard that covers the portability of running a command after variable assignment on the same line? APPLE="cider" echo hi How portable is something like that? Where will it work and ...
3
votes
2answers
1k views

Replace a pattern in a file with a long string

I'm writing a little shell script to generate a directory listing. To make the output easily customizable, the script just builds a HTML-table and than should replace a specific token in a template ...
22
votes
3answers
655 views

shellcheck is advising not to use basename: why?

I am trying out shellcheck. I have something like that basename "${OPENSSL}" and I get the following suggestion Use parameter expansion instead, such as ${var##*/}. From the practical point of ...
3
votes
2answers
137 views

Shell-independent way to cp dotfiles from a folder to another [duplicate]

I have two existing directories : foo: directory with dotfiles in it foo2: empty directory I would like to have a solution to copy all dotfiles in foo to foo2. I would like a solution that is not ...
28
votes
1answer
2k views

Does 'rm .*' ever delete the parent directory?

The expression .* is expanded by bash to include the current and parent directories: $ ls -la total 2600 drwxrwxrwx 2 terdon terdon 2162688 Sep 10 16:22 . drwxr-xr-x 142 terdon terdon 491520 Sep ...
2
votes
0answers
37 views

Is there a standard POSIX way of doing `tac` [duplicate]

Looks like at least IBM AIX and HP-UX don't have the tac command by default. Is there a way to do this using just basic posix standard shell utilities available on all UNIX systems? Furthermore, is ...
0
votes
1answer
41 views

Is there such a scheduler and is it feasible?

I read about a scheduling algorithm called EDD which always works on the next deadline and that is feasible. Would it also be feasible to within each time windows or slice, work on all processor or ...