help with creating a suitable config file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with creating a suitable config file
# 8  
Old 01-24-2011
Quote:
Originally Posted by Corona688
If you make your config file a shell script, your loading script could be as simple as source ~/.configfile
[..]
IMO source is a bashism. According to the POSIX spec a dot should be used:
Code:
. ~/.configfile

Shell Command Language

--
This page seems to be incorrect in stating that source is a "bourne shell builtin and a POSIX `special' builtin"
http://ss64.com/bash/period.html

Last edited by Scrutinizer; 01-24-2011 at 02:35 PM..
This User Gave Thanks to Scrutinizer For This Post:
# 9  
Old 01-24-2011
Quote:
Originally Posted by Scrutinizer
IMO source is a bashism.
I just tested [edit]seven shells on two OSes. BASH, CSH, ZSH, TCSH, two versions of KSH, and busybox ASH(which is a stripped-down descendant of a fairly old BSD bourne shell). The only one that did not have 'source' was an out-of-date ksh. The newer KSH was fine.

So, while I can see why you'd be sensitive to the use of that keyword, no, it's not a BASH-ism, and would appreciate it if you stopped trying to blame every bad shell habit on it. Nearly every imaginable shell has it except yours.

I considered using . but it's difficult to read, especially for people new to the language. They could easily skip the space and mistake it for part of the path.
# 10  
Old 01-24-2011
Of course it is in the csh and derivatives. In the Bourne shell derivatives it is present in bash. In ksh88 it is not there. In ksh93 it is added as an alias to .
In zsh source is like . but it differs in the sense that the current directory is always scanned first, which is not advisable....
In dash source does not work. Source is not in the POSIX specification.
# 11  
Old 01-24-2011
Quote:
Originally Posted by Scrutinizer
In the Bourne shell derivatives it is present in bash.
Certainly not just bash, if you've been listening.
Quote:
In ksh93 it is added as an alias to .
Not all ksh93 has it.
Quote:
In dash source does not work.
I'd consider that a bug, and suspect that will be fixed soon.

In any case you're ignoring the point: Shells that don't implement a 'source' are in the minority. That your preferred shell is in this minority doesn't change this.
# 12  
Old 01-24-2011
You are ignoring the point that it is not POSIX. I think it is in the interest of the forum that such an observation is made. The only other time I ever used the term "bash-ism" in of all of my posts, was to point out that something was not a bash-ism, so I feel your reaction is bit out of place.
dash does not have a bug, it tries to adhere to the POSIX specification. In zsh it is not a synonym to .
# 13  
Old 01-24-2011
I concede the point that it's not POSIX.

I don't understand why it's a BASH-ism however. This feature's present in modern versions of your own shell of choice, entire historical branches of others, some ancient bourne derivitaves, and things you might've not encountered at all. BASH gets enough bashing already, I think. Smilie
# 14  
Old 01-24-2011
I put forward that "in my opinion" it is a bash-ism, I am not stating a known fact. The reason I say this is that source was in the csh line of shell, but not part of the orginal Bourne shell, nor was it in ksh. Somehow it was re-introduced and I would suspect this is because of bash.

In zsh source is not the same as . so it may give unexpected results.
dash is a modern shell, BTW. It is /bin/sh on Ubuntu, so scripts will break if one uses source, and there are more Posix shells on e.g. HP-UX or Solaris (/usr/xpg4/bin/sh). One would have to test if it worked there. In the HP-UX man page there is no mention of "source" http://h20000.www2.hp.com/bc/docs/support/SupportManual/c02267598/c02267598.pdf
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 config file with specified parameters

I want to create a config file that has parameters that can be specified using - or -- (without an equals sign), as well as the ability to output the file using - or --. Could somebody point me to a generic script to do this? Say for example, I wanted to run MainScript and have it set alpha to 2... (1 Reply)
Discussion started by: multiverse22
1 Replies

2. UNIX and Linux Applications

Choosing a suitable emacs theme

Hi, It may sound silly or stupid, but I really have a problem choosing a theme for my emacs. I am using Ubuntu (12.04) and I use emacs on the x-console (emacs -nw) I have added the "emacs-goodies" package and tried all the themes in it to no avail. My eyes are not comfortable with all these... (0 Replies)
Discussion started by: faizlo
0 Replies

3. Android

Is FAT32 more suitable?

May I assume that there is no point to format your SD Card (assume you have the 32 GB size) to NTFS if the device can support SD Card of up to 32 GB and FAT32 maximum limit is also exactly 32 GB? "Crest Accountants Suite E316, Level 3 Oracle East Building 3 Oracle Boulevard Broadbeach QLD 4218,... (1 Reply)
Discussion started by: PheekaJabal
1 Replies

4. Red Hat

Apache virtual host config vs global config problem

Hi folks, I am trying to configure Apache webserver and also a virtual host inside this webserver. For Global server config: /var/www/html/index.html For virtual host config: /var/www/virtual/index.html Both client10 & www10 are pointing to 192.168.122.10 IP address. BUT, MY... (1 Reply)
Discussion started by: freebird8z
1 Replies

5. AIX

No Suitable Driver for MS Access database

Hi, I am running a JDBC:ODBC code to access .mdb file in my windows system successfully but, not able to access MS Access mdb file in AIX Unix box. when I am trying to run the same piece of code in AIX Unix box it is saying "No Suitable Driver". I need some immediate help. (0 Replies)
Discussion started by: thirunp
0 Replies

6. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

7. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

8. AIX

Which is suitable Tar or Backup command????

hi all im making a script for backing up a specific filesystem that is an output of our DB13(SAP) into tape..which is around 40g + which is suitable tar or backup command i heard tar has limitations ..i heard it can only backup upto 2 gig??? is this ryt? and ill put this into cron. ... (6 Replies)
Discussion started by: redmanshogun
6 Replies

9. Ubuntu

Most suitable operating system

I have a Toshiba Satellite 1135 laptop, and i want to install a fedora core edition in my external USB hard drive. I have Intel celeron 1.8 ghz processor 256 mb ram. Please suggest if there are other suitable linux OS which would be better than fedora core. (2 Replies)
Discussion started by: sunilryl
2 Replies

10. UNIX for Dummies Questions & Answers

fetchmail suitable for this task?

Hi all. I'm currently building my own webmail server but I will need to collect my mail from several different account scattered around the 'Net. I know fetchmail can do this. The problem I have is that my main POP3 mailbox at my ISP lumps all users' e-mails into one box. This means that... (0 Replies)
Discussion started by: DraconianTimes
0 Replies
Login or Register to Ask a Question