Ilonpilaaja
Ilonpilaaja

Reputation: 1249

trimming leading tabs

I have a makefile whose so-called "actions" are delimited by \t. When I need to execute these actions, the shell, of course, complains about \tgcc -o a filename.c Coomand not found. The search only yields how to trim leading/trailing tabs/spaces with sed. If, however, one is not allowed to use it, but only bash?

Example of such a "rule" is:

A : B C D E F G
\tgcc -o a A

\t here is only for clarity, in the actual file I press the tab key. What I need is to be able to read what follows after the tab character and execute it with eval or backticks. If I backtick what I read (i.e. without trimming the tab character off), the shell complains.

Upvotes: 0

Views: 288

Answers (2)

koola
koola

Reputation: 1734

If you only want to use bash, then you need to parse the file, remove \t and dump to a new file.

Something like this;

while -r line; do echo "${line//\t/}" >> new_makefile; done < makefile

Upvotes: 0

jhc
jhc

Reputation: 1769

You aren't supposed to actually write \t on the command parts of makefiles. Press the tab key to get the space needed.

A : B C D E F G
    gcc -o a A

EDIT - If you are using vi/vim, you may be using a command that replaces TAB with a set number of spaces (usually 4). Check that.

Upvotes: 1

Related Questions