The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

2

memset for (int i = 0; i < sizeof(data) - 1; i++){ data[i] = 'a'; } shouldn't be needed. Just use memset from string.h, which is indeed available in the kernel. sizeof You have this: int i = 0; i < sizeof(data) - 1; i++ but also this: pos + len < sizeof data ? len : sizeof data - pos Today I learned that the parens are needed on types ...


1

Good I like most of what you've done so far as is: Using [[ (double square brackets) for conditionals is a good practice. Using $() for command substitution instead of the classic backticks is also a good modern shell practice. Most of your variable substitutions are quoted. This is a good habit in case the variable contains spaces it won't get broken up ...


6

There are a few ways to programmatically get the docs, and one that I find cool to use is inspect. inspect allows you, among other things, to check what's in your file (module): import inspect import sys docs = {} # a dictionary module = sys.modules[__name__] # Gets us a reference to the current module for name, object in inspect.getmembers(module): ...


17

Here are a few comments. In general, your code deviates in surprising ways from the UNIX commands (and not just by missing flags or options): Your ls command does more than you claim it does. os.walk recursively "walks" down from the current directory, so it returns the content of all subfolders as well (without indicating in which subfolder each file or ...


2

I largely re-written the error handling functions. The reasons were multiple. Mostly, I needed greater flexibility, reliability and even a bit more general-purpose use. File func-color_support First, I created this separate file for defining colors and determining if terminal colors are supported: #!/bin/sh # do not warn that variables appear unused # ...


Top 50 recent answers are included