this post was submitted on 27 Jun 2023
1 points (100.0% liked)

Programming

43 readers
1 users here now

This magazine is dedicated to discussions on programming languages, software development, and coding. Whether you are a beginner programmer or an experienced developer, this is the place for you. Here you can share your knowledge, ask questions, and engage in discussions on topics such as coding languages, software engineering, web development, and more. From the latest trends and frameworks to tips and tricks for debugging, this category covers a wide range of topics related to programming.

founded 2 years ago
 

Quick question about Makefiles: is there any reason to put recipe lines inside parens? I'm not asking about variable expansion -- I mean an entire line. For example, see SuiteSparse: https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/Makefile

Normally, you would use parens to make sure you don't mess with your state, but each line of a recipe in GNU Make is effectively run in its own environment anyway.

I've seen it a few places now, so just wondering whether it is simply stylistic preference or if there is some effect I'm missing.

EDIT: Okay, did find one case where it could matter, although it doesn't apply in SuiteSparse. If you use the .ONESHELL special target, then all lines of your recipes run in a single shell, rather than each getting their own shell. In that case, if you wanted to get back something like the original new-shell-per-line behavior, you could wrap lines in parens as described above. TIL.

#programming

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here