0

macOS 12.1 here. In the man page for hdiutil there is this example for creating a disk image with a password.

Creating an encrypted single-partition image without user interaction:
       printf pp|hdiutil create -encryption -stdinpass -size 9m sp.dmg

This works. It creates a 9MB .dmg file with a password but I don't get to see what the password is. I know the "printf" is supposed to show something but I don't know what the "pp" that follows that does?

Richard Barber
  • 5,257
  • 2
  • 15
  • 26

2 Answers2

0

The command shown begins with printf pp|, that is the command printf, the two letters pp, and a pipe. printf outputs its argument (the two letter p's). The pipe has the effect of sending those two letter p's to the following command, which as you know asks for a password. Therefor the password you have given to the .dmg is pp.


Fun fact. The pipeline was invented in 1973 by Douglas McIlroy and later coded by Ken Thompson (Inventor of the B programming language).
Richard Barber
  • 5,257
  • 2
  • 15
  • 26
-1

OK, this was dumb. The example creates the .dmg file WITHOUT user interaction. The correct line is:

hdiutil create -encryption -stdinpass -size 9m sp.dmg

You'll get asked for the password. If only I read the description more carefully.