2

I've been trying to figure out what this line does for a few hours. I have to automate the step using ansible and can't find anything on the create command. Any help is appreciated.

echo -e "create /tmp/v8-install/lib/libv8_libplatform.a\naddlib out/native/obj.target/tools/gyp/libv8_libplatform.a\nsave\nend" | sudo ar -M

  • I don't think create is a command. BTW, I see that ar is an archive utility. – UniversallyUniqueID Apr 25 '16 at 17:30
2

That command is copying an ar archive from

out/native/obj.target/tools/gyp/libv8_libplatform.a

to

/tmp/v8-install/lib/libv8_libplatform.a

Here's an explanation:

  • echo -e "..." prints on standard output the string .... Every \n is replaced with a new line.
  • The | (pipe) operator sends the output from echo to ar -M.
  • ar is an archive utility (similar to tar or zip). The option -M is used to read commands from the standard input.
  • sudo is used to run ar as root.

That command is equivalent to running sudo ar -M and manually typing these lines:

create /tmp/v8-install/lib/libv8_libplatform.a
addlib out/native/obj.target/tools/gyp/libv8_libplatform.a
save
end
  • create (unsurprising) creates a new archive.
  • addlib copies all the contents of an archive to the newly created archive.
  • save and end are self-explanatory.

If you want to learn more, check out the documentation for AR.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.