Fetch source file from GitHub using command line tools?

1

This question is related to a question offsite at FATAL: MemorySanitizer can not mmap the shadow memory. The person who responded said:

Do simple tests (e.g. this one) work for you?

The link takes me to a GitHub web page at http://github.com/llvm-mirror/compiler-rt/blob/master/test/msan/stack-origin.cc, which include the HTML markup. That means I can't perform the following with wget or curl:

wget http://github.com/llvm-mirror/compiler-rt/blob/master/test/msan/stack-origin.cc
gcc -g2 -fsanitize=memory stack-origin.cc -o stack-origin.exe

I'm also trying to avoid the entire clone since I only need the one source file.

How do I fetch the actual source file from GitHub using wget or curl?

jww

Posted 2016-02-27T16:36:21.610

Reputation: 1

Answers

2

In the header of the code on the page, you can see Raw. If you check the URL of it by, for example, clicking it, you will see https://raw.githubusercontent.com/llvm-mirror/compiler-rt/master/test/msan/stack-origin.cc and that's what you have to know to use wget.

Gombai Sándor

Posted 2016-02-27T16:36:21.610

Reputation: 3 325

Thanks. So do we always use *http://raw.githubusercontent.com/* as the prefix? Is that the rule? (I ask because I presumed I needed to append something like *?source=raw* to the URL). – jww – 2016-02-27T17:00:29.130

I don't know (just guess so). But you can always check by downloading the formatted page and look for a similar line: <a href="/llvm-mirror/compiler-rt/raw/master/test/msan/stack-origin.cc" class="btn btn-sm " id="raw-url">Raw</a> – Gombai Sándor – 2016-02-27T17:04:44.007