I might be overly paranoid here, but using unquoted strings in shell scripts is asking for trouble. In this case the trouble would be that a home directory has a space char in it (which is very ill advised to do in first place, but if i would have gotten a penny for every idiotic decision i have seen on a system during my career i'd be stinking rich).
... ... ...
I agree that having <space>, <tab>, or especially <newline> in a directory (or any file) name is a bad idea. But, if the pathname in the variable HOME (for ~ expansions) or if a user's home directory in the system's user database (/etc/passwd on many systems) (for ~logname expansions) contains spaces, periods, question marks, asterisks, square brackets, parentheses, or other characters that could cause field splitting or pathname expansions, tilde expansions should still work. The standards explicitly state:
Quote:
The pathname resulting from tilde expansion shall be treated as if quoted to prevent it being altered by field splitting and pathname expansion.
But, of course, if a variable is set to something containing a tilde expansion, expansions of that variable still need to be quoted. If some idiot sets up a login directory named /home/my directory, login procedures will set:
for that poor user, but the command:
will set MY_UTILITY to the string /home/my directory/my utility. Having done that you can execute that utility with:
but trying to execute it with:
will attempt to run the command /home/my with arguments directory/my and utility (assuming default IFS settings).
Hi All,
I am having a issue in a script. I am trying to execute a select * from a scirpt to a database and printing the the sql string. The * in the sqltring is printing all the files in the directory. How to handle it ?
..
..
sql="select * from emp"
execute ($sql)
echo $sql
Here my... (6 Replies)
Hi Guys,
I have a raidz zpool that consists of four disks. 2x2TB, 1x1TB and 1x0.75TB.
Originally it was only 1x1TB, 3x0.75TB, and I had around 1.7TB of storage capacity. I've just switched out two of the 0.75TB disks for the 2x2TB ones. I did this one at a time and now the resilvering is... (2 Replies)
If one:
$ find -name 'some expression' -type f > newfile
and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory.
I am... (3 Replies)
:(
---------- Post updated at 01:51 AM ---------- Previous update was at 01:50 AM ----------
Not working
---------- Post updated at 02:04 AM ---------- Previous update was at 01:51 AM ----------
cp -p /home/* home/exp/*.`date`
i am using this (4 Replies)
Hello,
I have this problem.
I have script file, e.g.
#!/usr/bin/ksh
echo $MY_DIR
ls -lt $MY_DIR
I want to list the script but with MY_DIR variable expanded. E.g.
MY_DIR=/abc/xyz (in shell MY_DIR is set)
So I want to list the script and see:
#!/usr/bin/ksh
echo /abc/xyz
ls... (6 Replies)
Hi all,
I have a selection of files that contain several commands that write to a file and are started as background processes similar to below.
command_to_run_simulator -simulator_arguments > log_file 2>&1 &
command_to_run_simulator -simulator_arguments > log_file 2>&1 &... (2 Replies)
Hi,
I want to just expand the macros in a set of c files from a filelist which are in different directories. I don't want the header files included in the c file to be expanded. I have a perl script which does
gcc -E <infile> -I <path to search for header files> -imacros <infile>
But in... (1 Reply)