POSIX is an acronym for "Portable Operating System Interface", a family of standards specified by the IEEE for maintaining compatibility between operating systems.
32
votes
3answers
3k 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 ...
23
votes
2answers
1k 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?
17
votes
3answers
1k views
Difference between POSIX, Single UNIX Specification, and Open Group Base Specifications?
What are the differences between POSIX, the Single UNIX Specification, and the Open Group Base Specifications? I think their purpose is for determining if an OS is Unix?
17
votes
2answers
506 views
What is the point of the `cd` external command?
As referenced in this fine answer, POSIX systems have an external binary cd in addition to the shell builtin. On OS X 10.8 it's /usr/bin/cd. You can't use it like the builtin cd since it exits ...
12
votes
4answers
507 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 ...
11
votes
2answers
510 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., ...
10
votes
2answers
702 views
Why do some applications use ~/.config/appname for their config data while others use ~/.appname?
I've noticed that some applications put their configuration files to ~/.config/appname while others use ~/.appname (the classic way, AFAIK) for this. What's the sense in this distinction and what ...
10
votes
2answers
1k views
How do I test to see if an application exists in $PATH?
I'm trying to write all of my sh startup/env scripts to work with as much DRY and as much: "works on every *nix I clone it to", as possible. This means making sure that if I try to run code that's not ...
10
votes
4answers
542 views
keep duplicates out of $PATH on source
I have the following code that's source-d by my .shellrc
PATH="${PATH}:${HOME}/perl5/bin"
PATH="${PATH}:${HOME}/.bin"
export PATH
but if I make changes to other code and then source this file, my ...
9
votes
2answers
924 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 ...
8
votes
2answers
237 views
Newlines in filenames
I understand and accept the premise that defensive1 shell scripting is both prudent and, in the longer term, more sustainable.
Many of the answers to text processing questions here follow this ...
7
votes
1answer
138 views
Does POSIX guarantee that the standard utilities are in PATH?
In the "Command Search and Execution" section, the POSIX specification says that PATH is searched when finding a utility to execute (with some exceptions). Does the specification mention anywhere ...
5
votes
2answers
290 views
Where can I find official POSIX and UNIX documentation?
I am looking for official documents on all POSIX standards and specifications. I would like to be able t read the docs to get a better understanding of UNIX systems and how they work at a low level. ...
5
votes
4answers
778 views
sed on OSX insert at a certain line
So I've been using 'sed' on linux for a while, but have had a bit of difficulty trying to use it on OSX since 'POSIX sed' and 'GNU sed' have so many little differences. Currently I'm struggling with ...
5
votes
4answers
358 views
Is there a difference between these two commands?
cat a > b
and
cp a b
If they are functionally the same for all intents and purposes, which one is faster?
5
votes
1answer
264 views
A minimal POSIX conformant operating system
For educational purposes, I'd like to start with a POSIX compliant base, including a shell, basic utilities, and an ANSI C compiler, then see what kind of environments I can build by putting packages ...
5
votes
1answer
435 views
A couple arithmetic related commands, Dash, POSIX shell, sh, Increment
When pre/post incrementing a variable, in POSIX Shell, what is the difference between these two examples. They seem like they would have the same consequences, but would they be used differently? ...
5
votes
2answers
165 views
What is difference between [ and [[ in BASH? [duplicate]
Possible Duplicate:
using single or double bracket - bash
When should I use a single bracket? [
When should I use double brackets? [[
Are both POSIX compliant?
5
votes
1answer
33 views
IO and other shell commands when a program is not started by a terminal
I have several launchers on my desktop for various programs, and there is a "run in a terminal" setting for those launchers.
When I check that setting, the program runs from a terminal, and logs its ...
4
votes
2answers
129 views
What's the “Unix way” for a CLI app to report no arguments specified?
I'm developing an application which I'd like to follow the "Unix way."
What should I program it to do in case it is called with no arguments (which makes no practical sense):
display an error ...
4
votes
2answers
111 views
What would break if the C locale was UTF-8 instead of ASCII?
The C locale is defined to use the ASCII charset and POSIX does not provide a way to use a charset without changing the locale as well.
What would happen if the encoding of C were switched to UTF-8 ...
4
votes
3answers
115 views
Why is there a type for process ids (pid_t), but not for file descriptors (fd)?
I see that pid_t is typedef'd in unistd.h, and file descriptors are defined to be int in fcntl.h. But since they are used in similar ways, wouldn't it make sense to have a typedef for file ...
4
votes
1answer
102 views
Why not just use standard streams instead of using filenames?
While I understand that programs like mv need an actual filename as a parameter, programs like sort could just read from standard input and write to standard output like names | sort > names ...
4
votes
1answer
445 views
What does 'uni' mean in unistd.h
What does uni mean in unistd.h
Does it mean unix? or universal?
What is it?
3
votes
1answer
124 views
the return built-in
According to the Open Group,
[t]he return utility shall cause the shell to stop executing the current
function or dot script. If the shell is not currently executing a
function or dot script, ...
3
votes
2answers
91 views
POSIX test and -a
I checked a script of mine with checkbashisms and I got the following warnings:
possible bashism in check_ssl_cert line 821 (test -a/-o):
if [ -n "${ALTNAMES}" -a -n "${COMMON_NAME}" ] ; then
In ...
2
votes
2answers
47 views
Read umask for a user
Plenty of examples on how to set umask for a user... but how do you read (or uncover) the default umask for a given user (say the logged in user)
2
votes
1answer
146 views
Why does the local::lib shell code use eval and $()
using local::lib requires you to add a line to your ~/.shellrc
eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)
I don't understand what the point of using eval, and encasing the statement in $() ...
2
votes
2answers
65 views
what happens when a window manager is put to background
I am trying to understand the situation why .xsession file expects the last process to be in foreground otherwise it is supposed to stop X11 session.
I have a small stand-alone script. when I run ...
2
votes
2answers
131 views
find command for the newest 500 files in a directory tree and also be POSIX compliant
I am looking for a single line shell script or unix command to find the newest 500 files in a directory. Major constraints are it should be POSIX complaint and the directory can have tons of files.
2
votes
0answers
63 views
How do you write test cases for a web server that uses posix sockets? [closed]
I know how to test it experimentally by running the program, but ideally I would like to test each function I write as I write it. Usually I can't test my functions until I write a whole bunch of ...
1
vote
2answers
173 views
Is it better to archive/move mail based on mtime or ctime?
I have been using a perl script to archive mail found here
The script uses ctime to process and decide which month sub folder to place mail. In most cases this is fine since the ctime = mtime and ...
1
vote
1answer
127 views
What is difference between POSIX and bash and other shell scripts?
While going through many answers on Unix.SE, I come across many of them writing their contents w.r.t to Posix or Bash or some other standard. I know of some differences like some have arrays and some ...
1
vote
2answers
437 views
Should I end my text/script files with a newline? [duplicate]
Possible Duplicate:
What's the point in adding a new line to the end of a file?
What is considered better behaviour: to leave the last letter of the last line to be the last byte of a ...
1
vote
2answers
64 views
How to monitor the last PID assigned by the kernel?
To monitor process creation I'd like to periodically write the last PID assigned by the kernel to any process on the system (not just processes created by the PID-monitoring program) with a time stamp ...
1
vote
1answer
87 views
Linking “..” do somewhere other than parent directory and other strange fs beharviors
Can the entry ".." become linked to someplace other than the parent directory? Is it possible to cause "tar" to create this weird behavior?
Scenario: I have a pre-built compiler to a embeded system, ...
1
vote
1answer
43 views
POSIX head and tail not feature equivalent
The documentation for POSIX tail's -n option says that
The origin for counting shall be 1; that is, -n +1 represents the first line of the file, -n -1 the last.
So tail -n 10 (used later on the ...
1
vote
2answers
170 views
linux command to check POSIX message queue
We can check the details of system V message queue with the help of ipcscommand. Is there any command to check POSIX message queue in Linux?
1
vote
0answers
147 views
Obtain device name and mount point if partition label is known
How to obtain the partition device name and mount point when the file system
label is known?
There are several possibilities:
Linux
File system label to device name
The device name can be obtained ...
1
vote
1answer
503 views
Disabling readahead with hdparm or POSIX_FADV_RANDOM
From Linux kernel's doc the advice POSIX_FADV_RANDOM seems to disable readahead. But whent I disable Readhead using (sudo hdparm -A 0 /dev/sdb) I get huge degradation in performances; also noticed ...
1
vote
0answers
30 views
Open Group Base Specifications, Single UNIX Specification and POSIX [duplicate]
Possible Duplicate:
What differences are between POSIX and Single UNIX Specification?
Having asked about the relation between POSIX and Single UNIX Specification, I was now wondering what ...
0
votes
1answer
44 views
Why is brk(0) called?
On a first shell I run the command tail with no argument.
On a second shell I kill the first tail using strace to monitor the system calls.
qdii@nomada ~ $ strace kill 1713
execve("/bin/kill", ...
0
votes
1answer
297 views
POSIX and Bash, sh shorthand, for compound if statement
I prefer to do my sh commands in shorthand, And I prefer to be in POSIX. Truthfully, if the script can run on Dash, that is good enough. Which means using the test command [, not the extended [[.
I ...
0
votes
1answer
137 views
POSIX conformance: NetBSD 5.1 <sys/time.h> gettimeofday declaration
I'm compiling some code which requests POSIX 1003.1 1993 conformance via -D_POSIX_C_SOURCE=2.
The code includes the header <sys/time.h> and wants to call gettimeofday, but on NetBSD 5.1 there ...
0
votes
0answers
116 views
Bug in grep, possibly Mac specific? (braces governing parenthesized expressions containing brackets) [closed]
Consider the grep pattern \\([a][b]\\)\\{2\\}. This should match string "abab", no? But on my Mac (MacBook Pro, 10.6.8, GNU grep 2.5.1 copyright 2001) it does not. On other machines it does match even ...
-1
votes
2answers
123 views
Do BSD sockets give better performance than others eg. POSIX and other? [closed]
I am searching cross-platform techniques to write client-server applications on Mac. I used BSD sockets, Cocoa APIs but I need to know which would be better at performance.