From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Tue, 2 Jun 2020 07:22:27 -0600 Subject: [PATCH v2 06/10] rtc: add rtc command In-Reply-To: <3d3529b8-e018-07e8-cbd1-39946d61b2f0@prevas.dk> References: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> <20200519220117.24448-1-rasmus.villemoes@prevas.dk> <20200519220117.24448-7-rasmus.villemoes@prevas.dk> <3d3529b8-e018-07e8-cbd1-39946d61b2f0@prevas.dk> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Rasmus, On Tue, 2 Jun 2020 at 03:13, Rasmus Villemoes wrote: > > On 31/05/2020 16.07, Simon Glass wrote: > > Hi Rasmus, > > > > On Tue, 19 May 2020 at 16:01, Rasmus Villemoes > > wrote: > >> [..] > >> +int do_rtc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) > >> +{ > >> + static int curr_rtc = 0; > >> + struct udevice *dev; > >> + int ret, idx; > >> + > >> + if (argc < 2) > >> + return CMD_RET_USAGE; > >> + > >> + argc--; > >> + argv++; > >> + > >> + if (!strcmp(argv[0], "list")) { > > > > It is comment in U-Boot to just check the letters that are needed. So > > here you could do (*argv[0] == 'l') > > Yes, and I consider that an anti-pattern. It makes it impossible to > later introduce another (sub)command which starts with a > previously-unique prefix. Now, if that "just type a unique prefix" > wasn't official, so scripts were always supposed to use the full names, > it wouldn't be that big a problem (scripts written for later versions of > U-Boot, or U-Boots configured with more (sub)commands, could still fail > silently if used on an earlier U-Boot or one with fewer (sub)commands > instead of producing a "usage" error message), but > https://www.denx.de/wiki/view/DULG/UBootCommandLineInterface explicitly > mentions that as a feature (and says h can be used for help, which it > can't when the hash command is built in, perfectly exemplifying what I'm > talking about). Hah funny. Using an abbreviation is only possible if no other command starts with the same leters. It is certainly very risky to use abbreviations in scripts. I would not recommend it. Abbreviations are for interactive use. If you have auto-completion on you can use tab. But here we are talking about a sub-command, which is a bit more controlled, in that it doesn't depend on what other commands the user enables. Anyway, it's up to you what you want to do here. Regards, Simon