Can long flags be followed by a single character? [closed] - linux

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm aware that the general convention is that short flags (or single dash "-") is followed by a single character, and long flags (or double dash "--") is followed by multiple characters (usually an English word). Also, sometimes multiple short flags can be written like this as shorthand ("-l -c" as "-lc").
However, is this also valid "--c"? It seems to be breaking the aforementioned convention but is it fine as long is it's a unique flag identifier?
Tried searching the web but wasn't able to find any results on this.

Yes, as a general rule, neither your shell nor your kernel cares about the format of the arguments you pass to your command, as long as the program you're writing expects that format.
However, if by "can" you mean "does that respect the POSIX conventions of command arguments", then you should look at the Utility conventions part of the POSIX standard. In the last published version, there is no particular restriction against what you want here, therefore you should be fine.
That said, when you write programs for other people, try to apply the Principle of least astonishment. People usually expect single letter commands to be preceded by a -, so it is a good practice to follow the de-facto conventions when possible.

Related

Are there any builtin features of Go (the go compiler more likely) that address making your binary more tamper resistant? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a program that prompts for a PIN before performing particular actions. The PIN is stored, encrypted, in a local config file along side the executable binary. User enters PIN, program decrypts and compares to the stored value, if they are equal, ok, if not etc.
I'm aware this kind of security check could potentially be circumvented with forensic tools that alter the binary, in affect, changing the '==' to '!=' in the right place to make all the wrong PIN's pass the test in my example.
This may be a stupid question, as I know from the first 2 minutes of googling it's a big and challenging topic, but I still thought I should start with checking on features of the language/compiler I'm actually using first. So, are there any features natively available with Go to make this kind of attack harder to successfully perform?
No, there is nothing remotely like this in the official go compiler or standard library.

Searching for simple problems naturally solved using stacks [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I would like to know about simple problems that can be naturally solved using stacks with the usual interface (emptyS, isEmptyS, push, pop, top).
The complexity asociated to the context of the problem should be null. I can't touch topics like parsing, compiling or search algorithms at this moment. This discards many classical examples.
The most beautiful example I found so far is checking for balanced parenthesis in strings. In very few lines, without any other background, the exercise shows the utility of the data structure:
Another good example is procesing a string where the asterisk means to pop an item from the stack and a letter means to push it into the stack. The function must return the stack after the operations described in the string are applied to an empty stack.
If you can share some others problems, I will apreciate it very much.
Thank you in advance.
Though this question is too broad, I am going to give some other applications. Some of other common applications are -
Parsing
Recursive Function
Calling Function
Expression Evaluation
Expression Conversion
Infix to Postfix
Infix to Prefix
Postfix to Infix
Prefix to Infix
Towers of Hanoi
Some details can be found here.

Identifying programming language [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I've been given a very small snippet of code and it piqued my curiosity. I'm wondering what the language is. I'd like to put the snippet up but it belongs to someone else and they wouldn't appreciate it being posted.
Suffice to say that what I've received looks like a function with a *.sub filename.
The keyword macro is used A LOT with a macro name following the keyword, like a function call with what would appear to be arguments separated by a comma.
if statements are terminated by endif.
The program was written for an embedded device (SiLabs device if I remember correctly).
Comments are denoted by ;.
End of commands are denoted by and end of line.
I've programmed in C/C++/C# and so my broader programming experience is lacking. Does anyone know what language I'm referring to?
I'm going to guess 8051, based on the front page of the SiLabs website.
Should look something like this:
http://www.microapl.co.uk/asm2c/sample8051asm.html
To distinguish it from other assembly languages, you'd look for instructions like SETB, CJNE, DJNZ, and arguments like #R1, DPTR, ACC. 8051 can also address individual bits of some memory locations, written as ACC.7 or P0.1.
Definitely Assembly language, but syntax may vary. Different assemblers features different syntax, also syntax may vary depending upon hardware used.
For Ex comment syntax -
'#' are used for i386, x86-64 etc
';' are used AMD 29K family, motorola, PowerPC
Also some high level assemblers hides some abstractions
Sounds like an assembly language. Hard to tell for which micro controller/microprocessor it is for though.

What is the standard for documentation style in Bash scripts? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
The community reviewed whether to reopen this question last month and left it closed:
Original close reason(s) were not resolved
Improve this question
I am currently writing a Bash script that has a number of functions in it and would like to add docs to make other team members understand what the point of the function is.
Is there a standard "style" for documenting Bash scripts and the functions it contains?
I do understand I'm adding an answer to an old question, but I feel the tooling has improved lately and would like to give additional suggestions in order to help out others who are viewing this question.
I have recently found TomDoc.sh, which uses TomDoc style comments in shell scripts. The tool provided can then extract information and generate markdown or plain text documents.
Other tools also exist. BashDoc is modeled after the JavaDoc syntax, supporting a variety of tags. With RoboDoc you embed a C-style comment in your Bash code and it extracts the necessary information. Lastly, Apple uses HeaderDoc for its shell scripting. All three of these have a suggested style for the comments that you write.
If you wish to annotate your code more than generate documentation, shocco.sh may be what you'd prefer. It doesn't have a specific format and is designed for you to see human-readable text describing the shell commands that you are running.
Usually, I try to follow guidelines that are analog to the ones I use with other languages like C.
This includes a function header containing:
function name, short description and purpose
list of arguments and return values, with descriptions
list of all side effects (e.g., changes in variables or files)
To my understanding there is no standard for Bash doc.
But typically you would:
include a header to your bash file, with your name, copyright,
contact, and briefly what the script does
a usage() function that
explains how to launch and use your function.
a comment at the top of
each function to explain what the func does.

How do you spell/pronounce all the special characters and symbols [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
The community reviewed whether to reopen this question 5 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I sometimes need to look for information for a special portion of code. When this code concerns or contains a special character such as °, *, or #, they are not always recognized in search engines.
I often end up having to ask a new question because I do not know how to write these characters in plain text.
Can anybody provide a definitive source for how these special characters should be written in a searchable way (or pronounced)?
You need the Jargon file. Amongst all the fantastic definitions (in the glossary section) is a list of ASCII symbols and what they're called.
Sadly, a lot of these characters have multiple names, some of which are more or less popular depending on things like how old the speaker is, and what side of the Atlantic they are living on.
I found a table in this blog post, which has a lot of the names. It shows which are (in the author's opinion) Britishisms and which are the most common names for each. The problem is saying that authoratatively would probably take some kind of international study. Anything less would just be emphasising the Author's own background.
For instance, she says calling [] "square brackets" is a British usage. I've never been more than a couple hundred miles outside the USA, and that's what I've always called them. Her first listed name, "Box" I've never heard anybody use.
Windows character map (just click a character, and look in the status bar at the bottom of the application window)
By far the most complete and authoritative listing of special characters is the Unicode character database.
And be sure to check out the rest of the Unicode website.

Resources