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

3
votes
2answers
53 views

Portable POSIX shell alternative to Linux seq(1)?

I've noticed you can't really count on seq(1) being available on anything but Linux. What's a simple reimplementation of seq(1) I can bring with me written in POSIX (not bash) shell? EDIT: Note that ...
-1
votes
0answers
17 views

posix_spawn taking too much time to spawn a new python program from c++ [on hold]

I'm facing a problem where when I invoke my python program from c++ using posix_spawn it takes around 70ms-200ms based on how long main program was running. Is there anyway I can reduce this time, as ...
10
votes
4answers
1k views

Does POSIX limit the number of directories in the os root?

I'm trying to learn the POSIX standard. When using Unix, I have /bin, /etc, /dev, /media, and usually /opt, but is that standardized or up to your spec implementation? Could there be many directories ...
3
votes
2answers
42 views

Why were STREAMS marked obsolescent in POSIX.1-2008? [closed]

The POSIX.1-2008 XRAT rationale states that X/Open STREAMS may be removed from future versions of the standard, and that strictly conforming applications shouldn't use them, but it doesn't explain why....
1
vote
1answer
68 views

Why getting these “Permission Denied”s in POSIX find-grep readable?

I do in Posix find $HOME +perm 0666 -type f -exec grep -l "XSym" {} \; but get this which I do not understand find: ‘/home/masi/.dbus’: Permission denied grep: /home/masi/.viminfo: Permission denied ...
1
vote
1answer
72 views

Is there a linux distro that's UNIX certified? [closed]

Is there a Linux distribution certified with the Single UNIX Specification? What are the primary reasons that most distributions don't get certified?
79
votes
4answers
21k views

What exactly is POSIX?

I see POSIX mentioned often and everywhere, and I had assumed it to be the baseline UNIX standard.. until I noticed the following excerpt on a Wikipedia page: The Open Group The Open Group is ...
3
votes
2answers
99 views

POSIX description of cp -R

I just became really confused by the implementation of bash's cp -R command compared to how POSIX words what should happen Given the posix definition, I would expect cp -R srcDir existingDestDir to ...
4
votes
2answers
384 views

Posix command that moves cursor to specific position in terminal window

in school we have been assigned a homework in which we are suppose to print an ascii art into a terminal window. A input is data in format [x_coordinate, y_coordinate, char_ascii_value] (there is no ...
41
votes
5answers
7k views

difference between “function foo() {}” and “foo() {}”

I can define bash functions using or omitting the function keyword. Is there any difference? #!/bin/bash function foo() { echo "foo" } bar() { echo "bar" } foo bar Both calls to functions ...
67
votes
3answers
12k views

$VAR vs ${VAR} and to quote or not to quote

I can write VAR=$VAR1 VAR=${VAR1} VAR="$VAR1" VAR="${VAR1}" the end result to me all seems about the same. Why should I write one or the other? are any of these not portable/POSIX?
11
votes
2answers
439 views

Which character encodings are supported by posix?

POSIX defines the behavior of tools such as grep, awk, sed, etc which work against text files. Since it is a text file, I think there is the problem(s) of character encoding. Question: What is the ...
2
votes
1answer
35 views

Why is SIGHUP ignored by daemon(3) only in FreeBSD?

As part of the systemd tmux daemon() discussion on reddit, I've noticed that it's only the FreeBSD version of daemon() libc library call that ignores SIGHUP sigaction(2), but not OpenBSD or glibc/misc/...
1
vote
2answers
51 views

How to benchmark different shells [closed]

I want to know if shell 1 is better for a job than shell 2 with a test that I handle maybe with shell 3 for example ksh, dash, bash or zsh. I use a test script that builds my projects, starts it,feed ...
0
votes
1answer
38 views

Is there a minimal POSIX shell for OS X?

Is there a minimal POSIX shell implementation for OS X? I like to write fairly portable shell scripts and want to catch as many incompatibilities or bashisms up front as I can. I'm not intending to ...
0
votes
1answer
29 views

Checking that $((a * b)) evaluates in my own shell [closed]

POSIX seems to define that a shell should be able to evaluate like a calculator the expression $(( a * b)) where * is a binary operator +, - or *. I programmed such a calculator for my own shell and ...
2
votes
1answer
67 views

Differences between declared, defined, and set

In shell, what are the differences between a variable that is declared, defined and set? Does "declared" mean the identifier of the variable exists, but the storage and value of the variable do not? ...
3
votes
3answers
110 views

Reverse sequence of a file with POSIX tools?

Is there any clean, clear-cut POSIX equivalent to tac? Readability as well as succinctness should both be considered.
0
votes
1answer
37 views

Can all of fork(), exec() and system() be wrong? [closed]

I understand why it could be less than best practice if I write C code that executes shell commands by calling system() and that it's better to use exec and fork but then a very experienced C ...
0
votes
1answer
86 views

What is the meaning of xargs show limits output

You can use xargs to discover limits about the commandline you're using: $ xargs --show-limits Your environment variables take up 1901 bytes POSIX upper limit on argument length (this system): ...
-1
votes
3answers
57 views

Wrong parameters passed to tar command makes file1 unusable!

Wrong parameters passed to tar command makes file1 unusable!! Correct command to tar file is: $ tar cvf total.tar file1 file2 but upon using the below format I am not able to recover file1 $ tar ...
4
votes
1answer
65 views

Why does Gawk in compatibility mode split records in the same way as when GNU extensions are enabled?

I'm not sure if I found a bug in Gawk or if I'm misreading / missing something in gawk's man page. According to gawk's man page, when in compatibility mode, if RS contains multiple characters, only ...
3
votes
3answers
212 views

POSIX compliance of the cd program?

Is globbing and shell expansion same thing? I'm learning C by writing a custom shell and I'm also learning POSIX. Now I wonder if it is POSIX compliance that cd - takes you back and that ~ means home ...
1
vote
2answers
76 views

What's the POSIX way to read an exact number of bytes from a file?

Just hit this problem, and learned a lot from the chosen answer: Create random data with dd and get "partial read warning". Is the data after the warning now really random? Unfortunately ...
30
votes
5answers
4k views

Portability of “> /dev/stdout”

Occasionally I need to specify a "path-equivalent" of one of the standard IO streams (stdin, stdout, stderr). Since 99% of the time I work with Linux, I just prepend /dev/ to get /dev/stdin, etc., ...
38
votes
3answers
9k views

How can I test for POSIX compliance for shell scripts?

Probably the main thing that this website has taught me so far is the importance of writing portable shell scripts. Considering that POSIX is the closest thing to a common standard between all ...
3
votes
4answers
196 views

Check if a shell variable has more than one line using built-ins?

I can do this by calling the external utility sed (for a known non-empty $myvar) like so: if [ "$(printf %s "$myvar" | sed -n '$=')" -eq 1 ]; then echo "Your variable has only one line, proceeding" ...
1
vote
2answers
84 views

Is `var=value builtin` the same as `var=value; builtin`?

In my answer here, I used the construct: n=$1 shift Reading Token Recognition spec, I understand that the shell will parse that line into two parts - the variable assignment n=$1 and the builtin ...
12
votes
1answer
195 views

POSIX equivalent for GNU timeout?

The GNU coreutils timeout command is extremely handy for certain scripting situations, allowing for using the output of a command if it is quick to run, and skipping it if it would take too long. How ...
3
votes
1answer
68 views

Limit POSIX find to specific depth?

I noticed recently that POSIX specifications for find do not include the -maxdepth primary. For those unfamiliar with it, the purpose of the -maxdepth primary is to restrict how many levels deep find ...
2
votes
1answer
68 views

POSIX Awk sort array

I would like to sort an array with POSIX Awk, however I have discovered that: asort() asorti() PROCINFO["sorted_in"] are all GNU extensions. Can this be done with without GNU Awk?
-1
votes
1answer
37 views

POSIX, Unix, Linux and Minix: What is what? [closed]

I am confused by the many related terms in the topic "UNIX". How are the terms POSIX, UNIX, Linux and Minix related? Which one is the root of all etc...?
1
vote
0answers
17 views

Why do I need an `;` or newline in `echo hi| { cat; }`? [duplicate]

In bash and dash the examples echo hi | { cat ; } and echo hi | { cat } produce the intended result hi. However, echo hi | { cat } is a syntax error $ sh -c "echo hi | { cat };" sh: 1: ...
0
votes
1answer
39 views

How can i remove duplicates from the output of tshark output [duplicate]

sudo tshark -i ppp0 'tcp port 80 \ and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \ -R'http.request.method == "GET" && http.request.uri contains "/ABC/...
1
vote
2answers
59 views

Does filename expansion append a slash to a symbolic link?

From the manual of coreutils: Some GNU programs (at least cp and mv) allow you to remove any trailing slashes from each source argument before operating on it. The --strip-trailing-slashes ...
1
vote
1answer
62 views

How can I access the history buffer in sh? (not in Bash)

Is there a command history in sh, for example how to access it, and as well, how to ensure it is clear? To clarify shells here: let's say you've logged on to a non-Gui Linux system, and $SHELL is ...
0
votes
0answers
53 views

Is a pipeline made of simple commands?

From Bash Reference Manual A pipeline is a sequence of simple commands separated by one of the control operators | or |&. From POSIX 2013 A pipeline is a sequence of one or more commands ...
1
vote
3answers
300 views

Are & and ; unary or binary operators?

About the control operators & and ;, from POSIX 2013: For asynchronous lists, the format for running a command in the background is: command1 & [command2 & ... ] For sequential ...
0
votes
3answers
80 views

How to understand the definition of a simple command?

From POSIX 2013: A ‘‘simple command’’ is a sequence of optional variable assignments and redirections, in any sequence, optionally followed by words and redirections, terminated by a control ...
1
vote
2answers
73 views

How to understand this POSIX description about `(`, `)` and `test`?

From POSIX 2013: The XSI extensions specifying the -a and -o binary primaries and the '(' and ')' operators have been marked obsolescent. (Many expressions using them are ambiguously defined by ...
0
votes
1answer
31 views

Does find Command Do Match For Regexp Because Of Implementation?

In this case discussed: find (GNU findutils) 4.5.11 grep (GNU grep) 2.20 Let's say I have a directory that contains a bunch of files. I want to find the files named jtobdops02.key and jtobdops.02.cer....
10
votes
2answers
778 views

Is there a POSIX way of setting zeroth argument of a target application?

In bash you can use exec -a and in zsh you can alternatively also set ARGV0 to execute a program with a certain zeroth argument but is there also a POSIX way of doing so? As suggested in this one ...
3
votes
3answers
56 views

How to understand the order between expansions?

From POSIX 7: The order of word expansion shall be as follows: Tilde expansion (see Section 2.6.1), parameter expansion (see Section 2.6.2), command substitution (see Section 2.6....
0
votes
2answers
41 views

What is the difference between token identifier WORD and NAME?

In POSIX 7, the shell grammar (Section 2.10 in XCU) mentions several token identifiers. I am confused about two: WORD and NAME. What are their differences? For example, is a command's option WORD ...
7
votes
1answer
583 views

What does `\time`, `t\ime` and `\cd` actually do? (fun with backslashes in shells)

While discussing over the differences between /usr/bin/time and the shell (bash and zsh) built-in time, someone mentioned that one can use \time as a shorthand to get /usr/bin/time. First it seemed ...
4
votes
1answer
58 views

Bash script for showing newly introduced env variables

I'm making this test script to help me reverse engineer scripts in charge of setting the dev environment. The script: #env-changes #!/bin/bash TESTED_SCRIPT=$1 shift ENV_BEFORE=$(env | sort) . $...
3
votes
2answers
57 views

How to source `. filename` reliably?

The current POSIX spec does not specify any options for dot . builtin. If I do something like: $ echo 'echo .' > /tmp/-foo $ PATH=/tmp "$shell" -c '. -foo' then the result is varied between ...
8
votes
2answers
121 views

How to get filesystem info for a specific file?

What is the best way to find out file system information about a file. For example, if I have a file /media/xyz/path/to/file.ext And /etc/fstab contains //server1/Share1 /media/xyz cifs option1=...
2
votes
2answers
133 views

POSIX print function definition

Bash can print a function defintion: $ bash -c 'y(){ echo z; }; export -f y; export -f' y () { echo z } declare -fx y However this fails under POSIX Bash, /bin/sh and /bin/dash: $ bash --posix ...
0
votes
1answer
53 views

What is the safest (or most elegant or shortest) way to change to the directory from where a script is called?

I wondered what might be a safe or the Unix compatible way to change to the directory from which a script is called. These two methods even work in a directory with spaces and special characters in ...