NIX questions

Go To Last Post
19 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to include project information into the flash.
I put

find .. -name "*.c"     -ls > ../main/filelist.all
find .. -name "*.h"     -ls >>../main/filelist.all
find .. -name "make*.*" -ls >>../main/filelist.all

into my makefile.
One question is that most of the lines but not all do not have year

384802756    4 -rw-r--r--   1 brb      Administ     7727 Jan  4 10:49 ../inc/can.h
305648514    1 -rw-r--r--   1 brb      Administ      957 Feb 23  2006 ../inc/can_bt_init.h

The second is how to execute windows .exe file from the makefile?
Any ideas how to achieve the same result better?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> One question is that most of the lines but not all do not have year

IIRC, if the file is less than 365 days old, it will be displayed without
the year but with HH:MM instead.

Don't know, under 4.4BSD there's an option -T to ls that says "use full
timestamp, always". However, that's not available in the -ls option in
find, so you'd have to say:

find .. \( -name "*.c" -o -name "*.h" -o -name "make*.*" \) | xargs ls -lT

If the dot-dots in front of the filename annoy you, do it like:

(cd .. && find . \( -name "*.c" -o -name "*.h" -o -name "make*.*" \) | xargs ls -lT)

> The second is how to execute windows .exe file from the makefile?

It's a normal command to be used in the right-hand side (after a TAB).
It must be in the $PATH.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for your reply!

M:\16\sonde>find .. \( -name "*.c" -o -name "*.h" -o -name "make*.*" \) | xargs ls -lT
ls: invalid tab size: ../adc/adc.c

I have put .exe in the current dir.
When I run outside of makefile it it does what I want. When it called from the makefile it does run but

Quote:

Null pointer assignment

#include 
#include 


void main ( void ) {
  char s[512];
#if 0  
  FILE *in, *out;

  puts ("filelist");
  in  = fopen ( "filelist.all", "r" );
  out = fopen ( "filelist.inc", "w" );
  fputs ("byte file_list [] PROGMEM = {\"\r", out );
  while ( fgets ( s, sizeof (s ), in ) != NULL ) fputs ( &s[56], out );
  fputs ("\"", out );
  fcloseall ();
#else
  puts ("byte file_list [] PROGMEM = {\"\r" );
  while ( gets ( s ) != NULL ) puts ( &s[56]);
  puts ("\"" );
#endif
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is another attempt:

find .. -name "*.h"     -printf %p\t%s\t%Ac\\\n

and still unsuccessful :?:
What is weird that it works as expected from console window, but fail from a makefile.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you try the exec & shell combination for Makefile?

result = $(shell your_command)

BTW> I usually escape dots in "regex" expresions for find command like that: -name "*\.h"

Regards,
--
Artur Lipowski

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> I usually escape dots in "regex" expresions for find command like that: -name "*\.h"

But find uses globbing patterns, not regexps. So "*.h" is OK.

My guess is that the $PATH the Makefile is seeing is not correct. Unix does
not implicitly prepend "." to the PATH, unlike command.com or cmd.exe.

It's probably best to extend the system PATH by some kind of tools directory,
and place the compiled file into that directory. That way, the Makefile
will be independent of the current working directory.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The problem is that instead \t being "tab", \n "new line", \\ "back slash" I see printed t,n,\ correspondingly from the makefile while no problems what so ever from the console...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Add single quotes around that entire string.

The shell (Unix shell) invoked by make will otherwise interpret the \
as their own escape character.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Single quote partially helped \t and \n now do their thing, but \\ doesn't. %\ doesn't work as well

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, make also uses the backslash as an escape character.
Try writing all backslashes twice then.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jörg, that is exactly what I have isn't it?

Quote:
but \\ doesn't

find .. -name "*.c"     -printf '%p\t%s\t%Ac\\ \n'

This does what I want, but

Quote:
find: warning: unrecognized escape `\ '

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
T:\brb\tigre\pwm>ls *.[cC] -s --full-time
   1 -rw-r--r--    1 brb      Administ      151 Tue Jan 16 09:23:54 2007 STRTOK.C
   1 -rw-r--r--    1 brb      Administ      348 Tue Jan 09 10:07:24 2007 esc.c
   1 -rw-r--r--    1 brb      Administ     1711 Wed Nov 01 19:53:05 2006 pwm.c

T:\brb\tigre\pwm>make
find  . -name "*.[cC]" -printf '%p\t%s\t%Am/%Ad/%Ay %AH:%AM; \\ \n'
find: warning: unrecognized escape `\ '
./pwm.c 1711    01/22/07 12:35; \
./esc.c 348     01/22/07 12:35; \
./STRTOK.C      151     01/22/07 12:35; \

What is wrong with access time???

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

access time != last modification time

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks!
Do you know how to get rid of the warning?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> Do you know how to get rid of the warning?

Not without trying. All this make and shell quoting can really become
a pain in the butt...

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dl8dtl wrote:
> Do you know how to get rid of the warning?

Not without trying. All this make and shell quoting can really become
a pain in the butt...

Hey, NIX people!
Who knows how throw away this warning? warning? I already have THE pain in my own butt.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you tried to remove the escape sequences, one by one, to try to determine which one is giving the warning?
On my system it turned out to be the space after the \\ that messed it up. Just deleting the space (which you really shouldn't need as you are about to emit a newline) messes things up in other ways. The trick on my system was to escape the space also, like so:

C:\Documents and Settings\Johan>find  . -name "*.[cC]" -printf '%p\t%s\t%Am/%Ad/%Ay %AH:%AM; \\\ \n'

All you needed was to experiment a little :wink:

PS: I also tried out your find command (on a RedHat 9 system) and got no warning. Version of find reported there is 1.5k, and on my windoze system it is 4.1 . Go figure... :shock:

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are right! Now could you please tell me what is "\\\" mean? I put this space to separate \\ and \n otherwise \n is misinterpreted.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> what is "\\\" mean?

It doesn't mean anything. Only "\\\ " does mean something: it's an
escaped backslash, followed by an escaped space.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.