Questions tagged [posix]
POSIX is an acronym for Portable Operating System Interface, a set of standards defining programming APIs and utility behavior for Unix-like operating systems.
79
questions
0
votes
0answers
17 views
Attempt on basic input validation and functional programming in a POSIX shell
In spite of all the POSIX shell disadvantages, I am still sticking with it and I love its portability.
Recently, I was searching for a way of code re-use, which turns out to be functional programming ...
2
votes
1answer
48 views
*nix, *bsd, etc basic `tput` color setup
My goal with the below piece of POSIX shell code was to address the more platforms the better with shell tput colors. With this code, I now start all of my scripts, ...
5
votes
2answers
72 views
Log file name adjustment
I have the following code that takes user input "path" and adds the current time into the filename after the name part and before any extension (if it exists).
It seems a little hacky to me ...
1
vote
2answers
65 views
Regex to match each line in a file, with windows and/or linux line break included, even for missing line break at EOF
My requirement is to match each line of a text file, including the line terminator of each, at most excluding the terminator of the last line, to take into account the crippled, non POSIX-compiant ...
1
vote
0answers
22 views
Implementation of GNU shuf(1) now supporting nul characters
Some time ago, I implemented shuf(1), but it had an issue: it ignored nul characters in the input.
This new version tries to solve this problem (but uses the ...
3
votes
1answer
64 views
POSIX + BSD-extensions implementation of shuf(1)
I implemented GNU shuf(1) in C using POSIX system calls and some BSD extensions. You must compile it with -lbsd.
...
1
vote
0answers
39 views
sudoedit_enhanced written POSIX-ly (readlink possible problem?)
sudoedit_enhanced written POSIX-ly challenge
While creating sudoedit_enhanced POSIX (apart from ...
2
votes
1answer
87 views
POSIX shell function to “dump” all given arguments
My today's idea was to create a POSIX shell function to dump all given arguments, typical use would be to call it from a fucntion, where you already know some arguments are not well set (empty; not ...
13
votes
4answers
1k views
Light task-processing systems with zero dependency for Linux systems
I made a prototype for a task processing systems.
Architecture
Worker - is a entity that is processing one-by-one tasks for the same processor.
Processor - (also: executable, app) executable file (...
1
vote
2answers
87 views
Editing system files in Linux (as root) with GUI and CLI text editors #2 (final)
This is the second iteration of this question
A note to start with: the first iteration of this question can be found here:
Editing system files in Linux (as root) with GUI and CLI text editors
As ...
0
votes
3answers
101 views
Safer & simpler allocation functions and macros
I wrote a bunch of functions and macros for safer and simpler allocation. They are documented in their files.
Disclaimer:
The library requires POSIX extensions, GCC extensions, and LIBBSD ...
4
votes
2answers
86 views
Generic circular doubly-linked list v2
I've improved, with help of the answers and comments, the linked list that I posted yesterday. It's been through a lot of changes, and is much more useful and safe now.
I documented the linked list ...
2
votes
0answers
32 views
Bash script to scp specific, most-recent files from remote server
I'm writing a helper script that I wish to be able to share with my co-workers. We all work using macOS Mojave, but all have their own shell configurations. For example, I actually use ZSH and bash 5....
12
votes
3answers
1k views
Correctly applying the “rule of five” to a RAII socket wrapper
I was trying to create a simple RAII wrapper with rule of 5 for a TCP POSIX socket. My aim was to try learn how to apply rule of five in different situations, but this one was somehow tricky.
...
2
votes
1answer
96 views
Editing system files in Linux (as root) with GUI and CLI text editors
My intention is to POSIX-ly write one generalized function for running various text editors I use for different purposes through sudoedit, i.e. editing files as ...
3
votes
2answers
131 views
Generic error handler function for POSIX shell scripts
Intention
I came with the idea of generic, portable, highly reliable, and further customizable function for Shell scripts, written in POSIX, for error handling.
Purpose
The function shall find out, ...
5
votes
1answer
54 views
POSIX+ implementations of echo(1)
Ever wanted a strictly conformant echo(1) implementation on your system? Wait no more: I've built it!
What is it?
My first large-ish body of C code in a while.
...
9
votes
1answer
295 views
Custom malloc implementation
I have a malloc() implementation that relies purely on mmap. I'm fairly sure that it doesn't overwrite any of the internal ...
8
votes
0answers
129 views
Console arkanoid in C
On an Internet forum a person came with their homework, to write Arkanoid in a console - it seemed they wanted someone to do their homework for them so I did not respond. However, I found the task ...
1
vote
1answer
92 views
Bash Code to backup the history file in Linux [closed]
How is the logic, efficiency and can it be improved?
This is a snippet from my .bashrc file, I just wrote it.
The code is supposed to do this:
Backup my ...
7
votes
4answers
1k views
Calculating linux based octal file permission
I'm applying for a mid level devloper position.
In order to progress to 2nd interview, you need to pass a technical test.
One of the questions was to write a function to work out linux based octal ...
3
votes
2answers
88 views
POSIX shell function for asking questions
I've written a tiny function for asking questions intended for my POSIX shell scripts, where I often need user input.
The function takes 2+ arguments, where:
Is a string containing the question.
, 3....
3
votes
1answer
61 views
batch add users to nextcloud on docker with csv
I have a working script that will batch add users to an instance of nextcloud running on top of docker. This version is the result of changes made after asking this question.
I guess I'm looking for ...
2
votes
2answers
59 views
Lock file and interrupt signals in POSIX shell script running indefinitely
This script is running indefinitely as the Linux background process.
I have put an enormous effort to make this POSIX shell script containing an infinite loop shut down tidily along with the ...
2
votes
2answers
333 views
ttyname() implemented in Go
I'm rewriting GNU's coreutils in Go in order to learn Go better. I've implemented ttyname(3), and I'm looking for a general critique. I can't think of anything in particular I think I did poorly on. (...
3
votes
1answer
24 views
Is device mounted? Both UUID and device names accepted
I am trying to write is_device_mounted script, which in turn will serve a greater purpose in my home Linux system.
It does not even have an error reporting ...
2
votes
2answers
42 views
POSIX-ly finding a specific Java process
In this code I find a list all of the running java processes and give the below function a name to look for, it will do its best. But since I find my approach a ...
2
votes
1answer
73 views
C Recursive Opendir Wrapper to Sort Directories First (ascending/descending)
A recent post on StackOverflow about a recursive directory listing which produced an unsorted mixed file/directory list, sparked the stray thought of "What would it take to write a wrapper for the ...
3
votes
1answer
73 views
Easy to use code preparation script for CodeReview questions
We all face questions that forget to include their code. Sometimes all of it, sometimes only parts, that make the rest of the question unfortunately incomplete and therefore off-topic.
What if it was ...
16
votes
2answers
688 views
Interprocess Communication in a Farmer-Worker setup
The following code is my first C program I have made for an university assignment about Interprocess Communication. This involved creating a parent process, the farmer, and then creating a certain ...
1
vote
1answer
175 views
Detecting the total amount of RAM installed on a hardware from a Linux system using a POSIX shell script
Today, I gave myself a small task of detecting the total amount of RAM installed on a hardware from a Linux system using a POSIX shell script. I ended up using ...
0
votes
1answer
33 views
Shell POSIX OpenSSL file decryption script follow-up #3 (final)
From original very simplistic code: Shell POSIX OpenSSL file decryption script
I learned a lot both from the first follow-up review, and the second one as well, many thanks!
I just need one final ...
0
votes
1answer
49 views
Shell POSIX OpenSSL file decryption script follow-up #2
This question is the second follow-up of: Shell POSIX OpenSSL file decryption script
The first follow-up was: Shell POSIX OpenSSL file decryption script follow-up #1
Both of which have proven very ...
26
votes
6answers
11k views
Create a C style char** from a C++ vector<string>
I am dealing with some older C style APIs, like Posix execve that take a char**. In the rest of my code, I prefer to use a ...
6
votes
1answer
739 views
Shell POSIX OpenSSL file decryption script
Tonight, I tried to write a Bash OpenSSL file decryption script. Encryption script will follow in highly similar manner, so I think it's not necessary now.
Let's suppose we have an encrypted large ...
1
vote
1answer
105 views
Shell POSIX OpenSSL file decryption script follow-up #1
This question is the first follow-up of: Shell POSIX OpenSSL file decryption script
Please read it before you continue reading this. Thank you.
I only have one new problem solved and I would like ...
1
vote
2answers
172 views
Long-term archiving + encrypting shell script
Yesterday, I very quickly, in an hour, wrote the very first version of my long-term archiving + encrypting shell script.
I am aware it may have too many flaws, but none of them really prevent it from ...
5
votes
1answer
153 views
Lightshot Print Screen key linux handler - Follow-up #1
This question is a direct follow-up #1 of my previous question:
Lightshot Print Screen key linux handler
There were too many errors which I didn't see at the moment and I tried hard to fix them up ...
3
votes
1answer
157 views
Shell script for reading /etc/passwd into SQLite
I want to read 4 columns, namely UID, GID, username and home directory of specific users from /etc/passwd into an SQLite database. I found this to create many ...
5
votes
1answer
170 views
Interactive Linux upgrade script
One year ago, I asked for a review of Simple Linux upgrade script in Bash.
Conditions are slightly changed, and/or more accurate:
Code readability for the code user, making it simple to adjust the ...
3
votes
1answer
122 views
Lightshot Print Screen key linux handler
I haven't found any Lightshot Print Screen key linux handler publicly available.
So, I decided to write one today. It is a standard POSIX shell script.
I believe there is always space to get better, ...
5
votes
2answers
102 views
Goodgame Empire coin collector with random offsets in (almost-POSIX) Bash
Today, my goal was again to improve my POSIX shell scripting abilities.
In one MMO game called Goodgame Empire, there is possible to code yourself a coin (tax) collector. But that's of less ...
0
votes
1answer
380 views
POSIX shell script for generating pseudo-random numbers
My today's goal was to further practice POSIX shell scripting.
So, I decided to write the following POSIX shell script for generating pseudo-random numbers.
Any and all reviews would be appreciated.
...
2
votes
0answers
63 views
Shell script to manage passwords
To get my feet wet with shell scripting I wrote this "minimal command line
password manager" (aka pwm) taking inspiration from the well known ...
2
votes
2answers
47 views
How long a PID has been running (taking multiple inputs)
Tonight I tried to write a POSIX shell script which would allow me to check how long a process is running (via it's ID) and be able to handle multiple inputs:
...
2
votes
1answer
49 views
Implementing POSIX file mode library
I implemented a virtual file system library with POSIX file mode representation.
Any suggestions regarding optimization are welcome.
...
2
votes
1answer
3k views
C++ wrappers for execv(3)
Calling execv(3) (and similar functions) in C++ can be
problematic. execv expects an array of const pointers to
non-const ...
3
votes
1answer
78 views
Showing all programs' man pages
I'm trying to discover useful command line tools in Arch Linux, and it seems one good way of going about that is to look through all of the man pages related to ...
4
votes
0answers
953 views
SIGCONT Handler for terminal application
I'm writing a C++ application for POSIX environment with terminal-based User Interface. I'd like to make my application's UI be consistent between Ctrl-Z and ...
18
votes
3answers
11k views
Implementation of the ls command with several options
As part of a past assignment, I've expanded on this implementation of ls to have more options available, including non-standard ones.
It currently supports these (...