Bash shell: Creating Preferences


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash shell: Creating Preferences
# 1  
Old 05-19-2008
Question Bash shell: Creating Preferences

In OS X I'm currently writing a bash script that requires writing to preference file. I may eventually want to share it with users on other Unix-like OSs and would like to accommodate for that possibility ahead of time.

Most OS X applications save preferences in xml-format plist files. These preferences can be easily created, written and read even from the command line using the Defaults tool. Conventionally the plist files are stored within the user's home folder in ~/Library/Preferences/

Is there a similar preference management mechanism common to GNU/Linux or to BSD? Is there also a standardized location for storing preferences files?
# 2  
Old 05-19-2008
Nope, no such thing. Individual tools have their individual conventions. E.g. Gnome uses a similar mechanism but it's by no means widely supported outside of Gnome.
# 3  
Old 05-19-2008
I suspected a much. However that leaves my second question still unanswered: when distributing scripts which require the writing of preferences and caching of data to be used by future iterations- what would would be the standard or even just the polite path to store such files?
# 4  
Old 05-20-2008
Chapter 10 of The Art of Unix Programming: Chapter 10. Configuration documents the historical legacy in quite some detail. I wish I could point you to something better for future-proofing your solution. Your options are basically either create a dependency on some sort of XML library (if you are writing C code) or a dedicated configuration parsing tool (is this Defaults tool available as a port to other platforms?); or simply fall back to a stone-age flat-file format, with all its quirks and complications.
# 5  
Old 05-20-2008
On Ubuntu, apt-file search bin/defaults reports that the package gnustep-base-common includes a tool by this name. It sort of goes with something I meant to mention, but forgot; I guess the Mac tool is somehow descended from the NeXT toolbox. (Gnustep / OpenStep are an open-source reimplementation of the NextStep framework. See also GNUstep - Wikipedia, the free encyclopedia)

GNUstep defaults database looks like the Gnustep tool doesn't actually use XML at all, though.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating a condition on a bash script

I wrote a code to find codons in a DNA string. The only problem I have is how do I make the code only work for a file with DNA. This means the file only has the characters a,c,g,t and no white space characters. (3 Replies)
Discussion started by: germany1517
3 Replies

2. Programming

Creating a bash based restricted shell

Hello. I need to write a command line interface that can be invoked either directly from the shell (command sub-command arguments), or as a shell that can process sub-commands. i want to use bash auto completion for both scenarios. example: lets say my CLI module is called 'mycli' and there... (5 Replies)
Discussion started by: noamr
5 Replies

3. Shell Programming and Scripting

Creating .../ alias in bash

I want to create an alias as follows but is not working alias ../='cd ../' (3 Replies)
Discussion started by: kristinu
3 Replies

4. Shell Programming and Scripting

Creating variables in bash

I am writing some scripts using bash and am wondering if there is a better way to perform the following set of formatting variables. s1=" " s2=" " s3=" " s4=" " s5=" " s6=" " s7=" " s8=" " frmt_titl="${bYl}%s${nClor}\n" frmt1_titl="${s1}$frmt_titl"... (10 Replies)
Discussion started by: kristinu
10 Replies

5. Shell Programming and Scripting

Creating Printing Program in bash

HI I am trying to create a bash script to print whatever i type in It has to have these below to define the size of the label and what size to print the text N q609 A100,10,0,5,2,2,N," " P1 It has to be sent to below > /dev/usblp0 So what it has to be is Written... (12 Replies)
Discussion started by: bganse
12 Replies

6. Shell Programming and Scripting

creating own command interpreter like bash...??

Hello senior members, I am a fairly newbie here. I just want to ask one question that how can once create one's own command interpreter/ shell like bash in unix/linux. I need to execute basic commands like pipes and i/o. Any help in this matter ?? (3 Replies)
Discussion started by: duma188
3 Replies

7. UNIX for Dummies Questions & Answers

BASH - Creating a Matrix

I'm trying to create a Matrix using bash. The expected output is .AB CDE FG 1 2 3 4 5 6 7 I'm a newbie in shell language, really appreciate if there is anyone who can guide me with this. Double post again, continued here (0 Replies)
Discussion started by: vinzping
0 Replies

8. Shell Programming and Scripting

Creating variable using awk in bash

I would like to create a variable within my bash script using awk. I'm reading in a line from an external file, then outputting to a new file in a specific format. But, it doesnt quite work as I have expected and could use some help. (A pertinent excerpt of ) the bash code is: count=1 ... (4 Replies)
Discussion started by: snoitacilppa
4 Replies

9. Shell Programming and Scripting

Creating a command on a BASH shell

Hi all. Suppose I have the following function in an executable file named "HOLA": ------------------------ function hola { echo "Hola ${@}."; } ------------------------ In addition, suppose that I want to execute the file so I can input my name next to ./HOLA. I mean,... (4 Replies)
Discussion started by: hresquivelo
4 Replies

10. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies
Login or Register to Ask a Question