Questions tagged [portability]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
33 views

Are octal escape sequences more portable than hex ones for shell scripts

As part of a scheme for writing shell code that's capable of processing arbitrary data, I was looking for a way to convert null bytes to some other character. I found that tr requires arbitrary bytes ...
0
votes
0answers
26 views

Testing if a file descriptor is valid in really old shells

This is a follow-up question for "Testing if a file descriptor is valid." I am looking for a way to test whether file descriptors are valid that works, including with fds 0, 1, and 2, on ...
0
votes
1answer
49 views

How to make a shell script as portable as possible (POSIX and non-POSIX)

Situation: Writing a shell script to do some stuff across multiple shells Problem: While Bourne-compatible shell scripts (bash, ksh, ash, zsh, etc) are easy to be made portable (just make sure the ...
0
votes
1answer
42 views

Is it safe to hardcode /etc/ path for configurations in an application I'm contributing to?

The application I'm contributing to requires configuration files as a part of its operation. This is currently placed within the root directory of the application. If I followed the FHS, the config ...
0
votes
0answers
138 views

How to test a binary, to see if all shared library dependencies, are satisfied?

I have a program which I compiled on an earlier version of Fedora which suddenly broke after an upgrade. I was running an older version of Fedora at the time which had stopped receiving updates; so I ...
-2
votes
1answer
41 views

Linux off a Flash Drive

I want to run Linux off of a flash drive. I'm already dual booting Windows 10, and Ubuntu on my laptop, and have burnt the mint ISO onto a flash drive. Every time I load it live, it takes me to a ...
2
votes
1answer
53 views

process list with quoted arguments, portably

How can an original command issued at the command line be acquired without using proc or any other non standard tool? When printing a process list using ps, the arguments passed in to initiate the ...
2
votes
0answers
96 views

Portable way of finding files whose birth date is after a given timestamp

According to How to find creation date of file?, in Linux filesystems, such as ext4, Btrfs and JFS, that store the file creation time (aka birth time), it is possible to display the file birth time (...
0
votes
1answer
173 views

How to remap network interfaces on boot time?

It turns out that I'm trying to create a portable distro while getting prepared for any kind of hardware failure. I'm creating (or restoring) a Debian distro by multistrap (or from my backups) and ...
0
votes
4answers
780 views

How to write the most portable shell scripts? [closed]

I have been enthusiastic to shell scripting for some months, and found that the codes I write (in bash) do not work in some machines. This is very disappointing. I realize that I should have learned ...
5
votes
2answers
342 views

Does FreeBSD contain multiple variants of basic regex?

grep and sed are both described as using "basic regex" ("BRE") by default. BRE is well described here. But consider this output: # echo ' aaaaa ' | grep '\(aaaaa\|bbbbb\)' aaaaa # echo ' ...
0
votes
1answer
379 views

MX Linux Not giving me the USB option while trying to install on it

I have make bootable USB of MX Linux with the help of RUFUS software. Now when I am trying to install on USB it does not show me partition to install it while I am booting live setup . The choose the ...
2
votes
2answers
109 views

Why is the which command so hard to eradicate? [closed]

I'm coming from places like Why not use "which"? What to use then? and https://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script and am myself a long-...
4
votes
0answers
251 views

Convert an existing customised Debian 10 Installation to Live ISO

Can someone help please? I already did some research and found: Linux Respin completely messed up my system when trying to install dependencies (removed a lot of packages I needed) - at least I am ...
0
votes
0answers
26 views

Is it possible to have bash but not awk? [duplicate]

Here on Stack Exchange we often see answers on bash questions, that use tools other than the bash language, such as awk, sed, grep, etc. These tools are specific in POSIX, so they should be ...
2
votes
1answer
434 views

POSIX and Portability | shell scripts | grep -s, grep -q

I am all in for portability in regards to shell scripts. But I am unsure if I am overdoing it right now. In this example, we have a function called confirmation, which accepts the very first ...
4
votes
1answer
163 views

Does POSIX make not support globs in prerequisites?

I was reading the POSIX 7 Make definition, and I've noticed that prerequisites are almost always described as “files”: The make utility examines time relationships and shall update those derived ...
0
votes
1answer
140 views

Wildcards/Globbing: Are character ranges problematic?

In The Linux Command Line William Shotts claims that character ranges can be problematic. See the relevant excerpt below, emphasis is mine. Character Ranges If you are coming from another Unix-like ...
1
vote
1answer
250 views

Portable way to run command without PATH from bash script

cron calls my bash script (it's a backup script) with a very sparse PATH of /usr/bin:/usr. As a result, while a line like lvcreate --size 1G --snapshot ... works just fine when I run the script from ...
3
votes
2answers
100 views

Recommended way of checking only one running service?

I am writing a shell script to check if mongod server is running and if not, to start it. To acheive that I am using the below command: systemctl is-active --quiet mongod This does the job as ...
28
votes
3answers
3k views

Porting Linux to another platform requirements [closed]

I know that Linux is available and has been ported for many different platforms such as for X86, ARM, PowerPC etc. However, in terms of porting, what is required exactly? My understanding is that ...
3
votes
1answer
1k views

How does glibc within a Docker image survive different container host kernels?

Docker containers share the kernel of the host, but they do include their own applications and libraries. Is it correct that glibc is one of these libraries? If so, how come there is no problem of ...
7
votes
5answers
1k views

Portable check empty directory

With Bash and Dash, you can check for an empty directory using just the shell (ignore dotfiles to keep things simple): set * if [ -e "$1" ] then echo 'not empty' else echo 'empty' fi However I ...
3
votes
1answer
185 views

All-round 100% portable terminal color support check

Test for terminal color support using tput #!/bin/sh colors_supported() { command -v tput > /dev/null 2>&1 && tput setaf 1 > /dev/null 2>&1 } I am currently using ...
3
votes
0answers
121 views

What subset of Linux does recent WSL support? [closed]

I know well Linux but nothing about WSL or Windows. I'm using Linux since 1993, but I never used Windows (and probably won't use it before my retirement, e.g. before 2024, so I am likely to never use ...
4
votes
3answers
5k views

Do all different Linux distributions have the same command lines? [closed]

Do all different Linux distributions have the same command lines? What I want to know is the same command line works for all kinds of Linux distributions (CentOS, Fedora, Ubuntu, etc.) or whether they ...
5
votes
2answers
126 views

What makes a Linux distro portable?

What could possibly prevent me from detaching my current hard disk from the laptop and buy a new laptop, install the disk and resume from where I left? In other words, what prevents my current Debian ...
4
votes
3answers
2k views

Can I read a single character from stdin in POSIX shell?

Only read -r is specified by POSIX; read -n NUM, used to read NUM characters, is not. Is there a portable way to automatically return after reading a given number of characters from stdin? My usecase ...
0
votes
1answer
44 views

Portable way to run a simple script at startup

I'm trying to run a script at startup as root. (Just sets up a root-owned directory in /tmp). Currently, I'm using this script to set up the boot hook and it appears to get the job done: #!/bin/sh -...
-3
votes
1answer
157 views

Is pstree available on all Unices and Linux operating systems? [closed]

Is it a standard command that I can be assured is available on all standard-conformant operating systems? If so, what is the guarantee given by the relevant standard? Is it, conversely, a non-...
3
votes
0answers
70 views

What's wrong with putting do on the same line as for? [duplicate]

While reading about 11.12 Limitations of Shell Builtins I came across the following: To loop over positional arguments, use: for arg do echo "$arg" done You may not leave the do ...
3
votes
2answers
276 views

Is word splitting a part of POSIX?

I know that Bash has word splitting but zsh doesn't, and I'm not familiar with others(csh, tcsh, ksh, etc), but I was wondering if it is a part of any standard. In other words, does sh have word ...
2
votes
1answer
561 views

How to change the RS variable in AWK between files in a portable way

While looking at another question, I came across a problem I couldn't solve generally for awk, where if an awk program takes two files (i.e. to read entries from the first into an array to compare ...
1
vote
1answer
509 views

Availability of deprecated egrep and fgrep commands

Quite often I've seen answers mentioning that egrep is grep -E or fgrep is grep -F and using egrep or fgrep in their answers, even though these are technically deprecated. So I was wondering if ...
2
votes
2answers
145 views

How to locate one or more underlying disks when you know only a directory?

Assume that I have some device mounted to /backups. I'm copying selected files from the system to backup and I would like to reduce the amount of noise the device is making. I know that I can can use ...
0
votes
0answers
50 views

Portably determine listen ports in shell script

I have an init script for an application, and know the PID is available from the script. I am trying to add some logic to the status command to output the TCP listen ports associated with the PID. I ...
4
votes
2answers
2k views

Is the use of sed's “a” command to prefix a line portable?

I noticed the following interesting behavior: $ printf '%s\n' line{1..2} | sed $'1a\\\nPREFIX' line1 PREFIXline2 $ Interestingly, this behavior is only possible for the last command in a Sed script,...
1
vote
2answers
1k views

select(2) on FIFO on macOS

On Linux the included program returns from select and exits: $ gcc -Wall -Wextra select_test.c -o select_test $ ./select_test reading from read end closing write end first read returned 0 second read ...
2
votes
1answer
461 views

Multiple arguments in shebang lines

Linux only supports one argument in a shebang line: This: #!/bin/sh cat > pr_args <<'EOF' #!/bin/sh -e printf "'%s'\n" "$@" EOF cat > shebang <<'EOF' #!pr_args a b c EOF chmod +x ...
1
vote
0answers
104 views

Any *nix variant withOUT `/bin/cat`?

I'm writing a simple regression test for a tool like which(1) and someone pointed out there's no guarantee that there is always /bin/sh (AIX seems to have sh(1) as /usr/bin/sh, for example) and we ...
1
vote
3answers
1k views

How do I convert a relative to an absolute path, portably and robustly?

Suppose I'm running bash on a Unix-ish system - not necessarily Linux and not necessarily very new; and it may not have every bit of software I'd like. Now, I have a relative path for which I want to ...
14
votes
2answers
990 views

Do shells other than Bash and Zsh support ANSI-C quoting? e.g. $'string'

I have a shell script that uses the following to print a green checkmark in its output: col_green="\e[32;01m" col_reset="\e[39;49;00m" echo -e "Done ${col_green}✓${col_reset}" After reading about ...
1
vote
1answer
132 views

How to make an Ubuntu flashdrive portable to different computers? [closed]

I installed Ubuntu on my USB stick and everything works as expected on my main PC, but when I connect the USB stick to my laptop and try to boot it gets stuck in a boot-loop at the loading screen. ...
7
votes
4answers
1k views

What's the safest, most portable way to invoke the echo binary?

The echo in coreutils seems to be ubiquitous, but not every system will have it in the same place (usually /bin/echo). What's the safest way to invoke this echo without knowing where it is? I'm ...
13
votes
3answers
12k views

stat: modification timestamp of a file

I use stat -f %m .bashrc to get modification time of my .bashrc on osx. But when I run the same command on ubuntu, it spits error: stat: cannot read file system information for %m': No such file or ...
10
votes
5answers
7k views

Universal non-bash `time` benchmark alternative? [closed]

For comparing run times of scripts between different shells, some SE answers suggest using bash's built-in time command, like so: time bash -c 'foo.sh' time dash -c 'foo.sh' ...etc, for every shell ...
1
vote
0answers
1k views

How to run .phar file with PHP CLI from an unpacked RPM?

How to reproduce: "Install" PHP 5.4 (plus ncurses and OpenSSL libraries) from CentOS 7 repositories using rpm2cpio | cpio in a directory called "rpm" Download phpunit.phar version 4.8.26 Run ...
0
votes
1answer
278 views

Equivalent in Mono on Linux of GetUpdateRect on Windows?

I'm trying to compile in Mono on Lubuntu 16.04.1 a very helpful open-source Windows program, "Ketarin". It uses a function, "GetUpdateRect", which it finds in user32.dll, using this code: [...
1
vote
2answers
478 views

Widespread support for find with “-exec … +”? [closed]

Judging from the GNU findutils change log it had to be in GNU's find for at least a decade (also longer than that it was part of POSIX) so can it be safely assumed to be supported everywhere now? ...
1
vote
2answers
104 views

Need to update shell scripts so they can run in different *nix flavors

I have a bunch of ksh and csh scripts that need to be updated to run in different *nix flavors (red hat linux, hp ux, solaris). The shells are mounted in the home of each of our servers and we need ...