~amavect/mkexercises

8a8285bfe7baa108d19530ec89b174f6441c4adb — glenda 2 years ago 817b22f
update problem 00
2 files changed, 15 insertions(+), 13 deletions(-)

M basics/00/mkfile
M basics/00/mksolution
M basics/00/mkfile => basics/00/mkfile +12 -10
@@ 7,30 7,32 @@
myfile:
	echo 'I''m writing to a file!' >myfile

# If the user on the command line typed in 'mk myfile', it make it!
# If `mk myfile` is run on the command line, mk will make it.
# Try it!
# It does this by executing the recipe in rc, the command line shell.
# The recipe can be anything, even multiple lines, as long as rc can interpret it.
# If the user typed in 'mk myfile' again, it would return the file is up to date
# If the user typed in `mk myfile` again, it would return the file is up to date
#  and doesn't need to be made again.
# Your turn! Specify a target file named 'myotherfile' and create it however you wish.



# If you type in 'mk myotherfile', mk will detect that myotherfile is out of date
# If you run `mk myotherfile`, mk will detect that myotherfile is out of date
#  and run the recipe you wrote to create it.

# You can also specify multiple files as the targets for the same recipe.
# This is useful when a command generates multiple files, like yacc.

file1 file2 file3:
	echo 'my #1 file' >file1
	echo 'my #2 file' >file2
	echo 'my #3 file' >file3
	echo 'my #1 file' | tee file1 \
	| sed s/1/2/ | tee file2 \
	| sed s/file/data/ > file3

# (Note that there is a better way to write this recipe using Environment Variables.)
# (More on that in a later exercise.)

# Your turn! Write a target and recipe for 'file4' 'file5' and 'file6'.
# Your turn! Write a target and recipe for 'file4 file5 file6'.



# Run `mk myfile myotherfile file1 file2 file3 file4 file5 file6`
#  to see that all files get made.
# Check the mksolution file for ideas.
# Onto the next exercise!

M basics/00/mksolution => basics/00/mksolution +3 -3
@@ 5,9 5,9 @@ myotherfile:
	touch myotherfile

file1 file2 file3:
	echo 'my #1 file' >file1
	echo 'my #2 file' >file2
	echo 'my #3 file' >file3
	echo 'my #1 file' | tee file1 \
	| sed s/1/2/ | tee file2 \
	| sed s/file/data/ > file3

file4 file5 file6:
	echo 'foo' >file4