Mkdir fails when defined and called with functions.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mkdir fails when defined and called with functions.
Prev   Next
# 1  
Old 12-14-2016
Hammer & Screwdriver Mkdir fails when defined and called with functions.

In the below script i found that the alias mkdir_s is getting invoked from function configure() i.e the alias is kicking in.

Code:
#!/bin/bash -e
shopt -s expand_aliases

alias mkdir=mkdir_s
mkdir_s(){
if [[ -d $1 ]]; then
return
else
/usr/bin/mkdir "$1"
return
fi
}

configure()
{
mkdir -p /tmp/logs
}

configure

Inside the mkdir_s function it is also able to check the condition if the directory does not exist and executes the mkdir command. but then, I get the following error as the output.

Quote:
mkdir: usage: mkdir [-m mode] [-p] dirname ...

Can you please explain why and what is the fix ?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[solved] awk: placement of user-defined functions

Hi folks, is there any recommendation, especially from a point of performance, about where to place a user-defined function in awk, like in BEGIN{} or if it is only need once at the end in END{}? Or doesn't it matter at all since, awk is so clever and only interprets it once, wherever it is... (3 Replies)
Discussion started by: zaxxon
3 Replies

2. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

3. Shell Programming and Scripting

User defined functions in awk

Hi; Is der ne to to use user defined functions for the values in awk find $1 -type f -ls | nawk '{{print "|"$3"|"$5"|"$6"|"$8"|"$9"|"$10"|"} for(i=11;i<=NF;i++){printf("%s",$i)}}' In above command i want to append some values returned by user functions on line. thnks; ajay (1 Reply)
Discussion started by: ajaypadvi
1 Replies

4. Shell Programming and Scripting

Perl script to find where functions is called in c

Hello, I need to write a perl script to find where functions is called in c files.. The script should scan the file and find out the function names and then search to see where they are called... Lets for now assume all functions are internal. I don't know where to start :( ... (4 Replies)
Discussion started by: bojomojo
4 Replies

5. Emergency UNIX and Linux Support

Functions defined in header / cpp file behaves different

File: A.h class A { public: struct x X; int show() { x.member_variable ? 0: -1; } }; Now if A.cpp is complied which includes A.h (which is actually in a huge project space) we see that x.member_variable value is not as expected. But if remove the show() method and place... (4 Replies)
Discussion started by: uunniixx
4 Replies

6. UNIX for Dummies Questions & Answers

Expect "interact" fails when called from another script

So, I have an expect script (let's call it expect.exp) that takes 3 arguments. It logs into a remote server, runs a set of commands, then hands control over to the user by the "interact" command. If I call this script from the command line, it works properly. Now I'd like to apply this script... (2 Replies)
Discussion started by: treesloth
2 Replies

7. Shell Programming and Scripting

user-defined functions, "$@", $jobs and $ps wwaxu

Imagine a user-defined function. func() { /usr/pkg/bin/program long-string-of-switches-and-configs "$@" ;} I execute it once. Then background it. I execute another instance. Then bg it. func unique-user-input ^Z func unique-user-input ^Z First I view with ps ps wwaux ... (0 Replies)
Discussion started by: uiop44
0 Replies

8. Shell Programming and Scripting

Shell Script to display function names (called & defined) in a C++ Source Code

Hello to all, I am looking for a way to display only the names of function (calls & definition) of a C++ source code.There is already a post related to this, but the script is to find the functions using a specific variable, and the replies are not that convincing since they cannot be used for... (2 Replies)
Discussion started by: frozensmilz
2 Replies

9. UNIX for Dummies Questions & Answers

finding called functions recursively

I want to write a shell script which traverses a cpp file. Suppose there is function fncn_name6 .. which is called by fncn_name5 which in turn called by fncn_name4 and so on .. in a single cpp class. ie fncn_name1 { fncn_name2 { fncn_name3 } { fncn_name4 } } so fncn_name1 is... (2 Replies)
Discussion started by: ultimatix
2 Replies

10. Windows & DOS: Issues & Discussions

Samba (SMB) client fails: "Called name not present"

Hi, I issue smbclient on a Linux REd hat server : smbclient -L ***.16.0.42 -U domaine/Administrator Password: Domain= OS= Server= Domain= OS= Server= Sharename Type Comment --------- ---- ------- IPC$ IPC IPC distant ... (0 Replies)
Discussion started by: big123456
0 Replies
Login or Register to Ask a Question
update-fonts-alias(8)					      System Manager's Manual					     update-fonts-alias(8)

NAME
update-fonts-alias - compile fonts.alias files SYNOPSIS
update-fonts-alias [OPTION] directory ... DESCRIPTION
update-fonts-alias assembles a fonts.alias file in an X font directory using one or more alias files found in a subdirectory of /etc/X11/fonts/. It is typically invoked only from the post-installation and post-removal scripts of a package containing X Window System fonts that provide aliases for their XLFD names, but may be invoked at any time to reconstruct fonts.alias files. For each directory, which is simply the last component of its path (such as '75dpi' or 'misc'), update-fonts-alias will assemble either /usr/lib/X11/fonts/directory/fonts.alias or /usr/share/fonts/X11/directory/fonts.alias from the files found in /etc/X11/fonts/direc- tory/package.alias. This enables multiple packages to provide aliases for fonts in the same directory. No font package actually provides the fonts.alias file in the X font directory itself, so there is no danger of overwriting one package's aliases with those of another. For instance, the two packages 'xfonts-base' and 'xfonts-base-transcoded' may both install fonts into the directory /usr/lib/X11/fonts/misc. They each place their fonts.alias files in /etc/X11/fonts/misc/xfonts-base.alias and /etc/X11/fonts/misc/xfonts-base-transcoded.alias (respectively). update-fonts-alias concatenates these two files (as well as any others that match /etc/X11/fonts/misc/*.alias) into /usr/lib/X11/fonts/misc/fonts.alias. The format of fonts.alias files is described in the mkfontdir(1x) manual page. An example of how to use update-fonts-alias in package maintainer scripts is provided in the Debian Policy Manual. OPTIONS
-h, --help displays a brief usage message and exits. OPERANDS
update-fonts-alias takes one or more X font directory names to operate on as operands. Only the final path component of the directory name should be specified; e.g., update-fonts-alias 75dpi is correct, while 'update-fonts-alias /usr/X11R6/lib/X11/fonts/75dpi' and 'update-fonts-alias /usr/lib/X11/fonts/75dpi' are not. ENVIRONMENT
COLUMNS indicates the width of the terminal device in character cells. This value is used for formatting diagnostic messages. If not set, the terminal is queried using stty(1) to determine its width. If that fails, a value of '80' is assumed. DIAGNOSTICS
Errors usage error: one or more font directories must be provided update-fonts-alias was invoked without operands. Supply one or more X font directory names to operate on. usage error: unrecognized option update-fonts-alias was invoked with an unrecognized option argument. Use only the options documented in "OPTIONS", above. fatal error: path to X font directory must be used A directory name was supplied that was not an X font directory name. Supply X font directory names only. Warnings warning: absolute path directory was provided Usage of absolute paths is deprecated. Use only the final component of the X font directory name for directory. warning: directory does not exist or is not a directory The supplied directory was invalid. update-fonts-alias skipped it. EXIT STATUS
0 update-fonts-alias ran successfully. 1 update-fonts-alias experienced a fatal error; see the section on diagnostic messages above. 2 update-fonts-alias was invoked with invalid arguments. BUGS
See the Debian Bug Tracking System <http://bugs.debian.org/xfonts-utils>. If you wish to report a bug in update-fonts-alias, please see /usr/share/doc/debian/bug-reporting.txt or the reportbug(1) command. AUTHOR
update-fonts-alias was written by Branden Robinson. SEE ALSO
mkfontdir(1x) Debian Project 2004-11-11 update-fonts-alias(8)