Find the answer to your Linux question:
Results 1 to 4 of 4
Hi I would like to put out something which i came across today. i dont know why it is happening like that Suppose path=hello In makefiles suppose we want to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    May 2005
    Location
    Chennai,TamilNadu, India
    Posts
    141

    Makefiles and script files


    Hi

    I would like to put out something which i came across today. i dont know why it is happening like that

    Suppose

    path=hello

    In makefiles suppose we want to print the varibale path.
    It should be done in the following manner

    Code:
    echo $(path)
    The above will print the string hello

    if given as
    Code:
    echo $path
    then it will print an empty string


    It is vice versa in script files

    what change does the brackets make in makefiles and script files?

    or is it like take it for granted the way it is

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Parentheses are used in Makefiles to reference variable names ( the exception are one-character names like 1, d, or a, which are $1, $d, and $a ).
    This is just the way things are.

  3. #3
    Linux Newbie
    Join Date
    May 2005
    Location
    Chennai,TamilNadu, India
    Posts
    141
    thanks laker

    actually i was sitting with this issue by giving wihout the brackets in the makefile and wondering why it was not coming the string that was assigned to it

    anyway now i can keep that in mind whenever I do something like this

  4. $spacer_open
    $spacer_close
  5. #4
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    In shellscripts you use braces { } to enclose shell variables, handy if you want to append characters to variable values, eg
    Code:
    string=myfile
    echo ${string}a  ${string}b
    Without the braces the shell would look for variables "stringa" and "stringb" and (probably) return nulls, when what you want is "myfilea" and "myfileb".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •