Linux Compatibility


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux Compatibility
# 8  
Old 08-08-2016
Hi Robin,
In POSIX-conforming shells (or any shell based on Bourne shell syntax that I know of), field splitting and pathname expansions do not occur when assigning a string to a variable. So, in your example, the assignment:
Code:
filename=INPUT_GIANT_*.csv

shouldn't cause any problem. But if the file's name had been:
Code:
INPUT_GIANT_123;rm -rf * .csv

then in some contexts, expanding $filename unquoted could result in attempting to remove all files in the file hierarchy rooted in the current directory (except hidden files in the current directory) and then attempting to remove the hidden file named .csv from the current directory and, if it was a directory, all files in the file hierarchy rooted in that directory.
# 9  
Old 08-08-2016
Thanks Don,

Maybe I'm being paranoid, but I feel sure there are things going to bite me Smilie

I just know that I've been caught out before when trusting filenames on disk, standard messages in log files etc. so I'm just always careful when reading input to try not to assume that it's all good. If this discussion makes people consider the bad things that can happen, then I'm all for it. The worst example I found was the evil eval being used to execute files, something like:
Code:
#
#
# Setup and code for creating a set of 'build-scripts' that are then
# run in parallel for no good reason that I could ever work out
#
# then it went:.....

for file in *.build-script
do
   eval $file > $file-out &
done
wait
exit 0

How may ways was this so wrong? Well, it's all gone now but it highlights what a mess we can make if we're not careful

Having inherited it, it ran in the overnight batch for a few months silently doing the job, but it went VERY badly wrong and it was effectively DR time as we lost /etc making login a little difficult ....... Smilie
# 10  
Old 08-08-2016
Hi Robin,
You're not being paranoid. Assigning a pathname matching pattern to a variable won't expand the pattern during the assignment (so that isn't inherently dangerous). But, expanding that variable unquoted is a completely different matter. And expanding it with eval (quoted or unquoted) gives you MUCH more to be concerned about.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. BSD

OpenBSD fdisk - Linux fdisk compatibility ?

Hello, MBR partition table made by linux fdisk looks certainly not correct when printed by openbsd fdisk: Partition table created on linux (centos 6.3): # fdisk -l /dev/sdc Disk /dev/sdc: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 *... (2 Replies)
Discussion started by: vilius
2 Replies

2. Solaris

Solaris 10 - HW compatibility

Sorry, if this isn't the right forum for this question. I would like to compile an executable with gcc/g++ under Solaris 10 on the following OLDER SPARC-machine and then run this executable on the NEW SPARC-machine (see description down in this post). I'm wondering if it would be possible or if... (4 Replies)
Discussion started by: sunfire
4 Replies

3. SCO

Binary compatibility

Hi I'm going to buy C-ISAM 7.25 under sco unixware 7 to install in sco openserver 5.0.7. I'm wondering sco unixware 7 and sco openserver 5.0.6 are binary compatibles ? tnx (1 Reply)
Discussion started by: javad1_maroofi
1 Replies

4. Hardware

Linux Hardware Compatibility Guide (2007 HOWTO)

Before posting questions about Linux hardware, it is a good idea to check the Linux Hardware HOWTO guide (Last Update: 2007-05-22) However, this HOWTO has not been maintained since 2007 and it out-of-date. (0 Replies)
Discussion started by: Neo
0 Replies

5. Linux

Linux-laptop compatibility debate

Hey guys, i use my mac laptop and i love it, but i have decided its time to break the mold and use linux, and since linux on macs suck, i need to know what kind of pc to build... I want to know what kind of motherboard, wireless cards, hard drives, laptops, video cards, and etc. people have had... (3 Replies)
Discussion started by: mesaynaysayer
3 Replies

6. SCO

SCO 5.0.6 application compatibility w/ Linux?

Hello Valued Members, I was wondering if there are any Linux, BSD, versions that can run SCO 5.0.6 applications without much modification? I was looking into purchasing a copy of Caldera Openlinux, the last version, but wanted to ask if there are any other options of a newer variant. I am also... (8 Replies)
Discussion started by: stay0ut
8 Replies

7. Solaris

Disks compatibility

Hi all, I am trying to isntall veritas replicator on 2 DA 3000 storage , But with little luck . I am running a solaris 10 and vsf 4.1, Veritas Volume Replicator Option 4.1 My question is that : when i got the array i had 2 disks missing , So we had to replace them , but I found out that... (0 Replies)
Discussion started by: ppass
0 Replies

8. UNIX for Dummies Questions & Answers

Linux & Unix Compatibility

I am looking for a dual XEON or any dual CPU motherboard that can support Linux and Solaris at the same time. Does anyone have any idea? I am now looking at the TYAN S2507T / TYAN S2505T / TYAN S2720, you guys have any clue?:confused: (6 Replies)
Discussion started by: doyho
6 Replies

9. Shell Programming and Scripting

compatibility problem ??!!

hi! i have two problems with the following script who prepares a date (removes the heading zero from day if day<10) for arithmetical operations: <script> #!/usr/bin/sh DAY=`date +%d`; echo 1 - $DAY;#i.e. 06 DAY=${DAY#0}; echo 2 - $DAY;#i.e. 6 </script> 1. every time i run this... (3 Replies)
Discussion started by: oti
3 Replies

10. Filesystems, Disks and Memory

Motherboard Compatibility

Hi there,, I URGENTLY need to know if the Gigabyte GA 8IDML Motherboard is compatible with the Unix BSD. We need to know if we should buy new boards before we can use the product. Thanking you Hannelie Bosch:confused: :confused: (1 Reply)
Discussion started by: hbosch
1 Replies
Login or Register to Ask a Question