From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00010702.pphosted.com (mx0a-00010702.pphosted.com [148.163.156.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 78CF921A0BAA9 for ; Mon, 15 May 2017 14:27:08 -0700 (PDT) Received: from pps.filterd (m0098781.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4FLPT6c019291; Mon, 15 May 2017 16:27:03 -0500 Received: from ni.com (skprod3.natinst.com [130.164.80.24]) by mx0a-00010702.pphosted.com with ESMTP id 2aegd0ege6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 May 2017 16:27:03 -0500 Received: from us-aus-exch1.ni.corp.natinst.com (us-aus-exch1.ni.corp.natinst.com [130.164.68.11]) by us-aus-skprod3.natinst.com (8.16.0.17/8.16.0.17) with ESMTPS id v4FLR1Ob004315 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 15 May 2017 16:27:01 -0500 Received: from us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) by us-aus-exch1.ni.corp.natinst.com (130.164.68.11) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Mon, 15 May 2017 16:27:01 -0500 Received: from jmw-lm181.ni.corp.natinst.com (130.164.49.7) by us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Mon, 15 May 2017 16:27:01 -0500 Date: Mon, 15 May 2017 16:27:01 -0500 From: Jeff Westfahl X-X-Sender: jwestfah@jmw-lm181 To: Tim Lewis CC: Jeff Westfahl , "edk2-devel@lists.01.org" , Ruiyu Ni , Jaben Carsey In-Reply-To: <7236196A5DF6C040855A6D96F556A53F57E66F@msmail.insydesw.com.tw> Message-ID: References: <1494882113-19051-1-git-send-email-jeff.westfahl@ni.com> <7236196A5DF6C040855A6D96F556A53F57E66F@msmail.insydesw.com.tw> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-15_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_policy_notspam policy=outbound_policy score=30 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=30 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705150203 Subject: Re: [PATCH] ShellPkg/Touch: Create file if it doesn't exist X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 May 2017 21:27:08 -0000 Content-Type: text/plain; charset="US-ASCII"; format=flowed Hi Tim, I think those are reasonable arguments. It's probably best to just leave the touch command alone. It sounds like we've gotten along fine with the existing behavior for quite a while. Regards, Jeff On Mon, 15 May 2017, Tim Lewis wrote: > I don't think it is good to change the behavior of the tool beyond what is in the specification. Further, this tool has existed for quite a long time in the EDK shell and now the UEFI shell without this behavior. So the de-facto standard of this environment is "don't create". Leaving behind stray 0 byte files would be an unwanted side effect for existing scripts that use this command. > > Further, this doesn't add any corresponding command-line options to , and certainly not without corresponding command-line options like -c to disable this behavior. > > Thanks, > > Tim > > > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jeff Westfahl > Sent: Monday, May 15, 2017 2:02 PM > To: edk2-devel@lists.01.org > Cc: Ruiyu Ni ; Jaben Carsey > Subject: [edk2] [PATCH] ShellPkg/Touch: Create file if it doesn't exist > > The UEFI Shell touch command returns an error if a file to be touched doesn't exist. In other command line operating environments, the touch command typically creates a file if it doesn't exist. This patch updates the UEFI Shell touch command to follow this convention. > > Cc: Ruiyu Ni > Cc: Jaben Carsey > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jeff Westfahl > --- > ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c > index 639346f..921de5a 100644 > --- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c > +++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c > @@ -175,11 +175,13 @@ ShellCommandRunTouch ( > UINTN ParamCount; > EFI_SHELL_FILE_INFO *FileList; > EFI_SHELL_FILE_INFO *Node; > + SHELL_FILE_HANDLE FileHandle; > > ProblemParam = NULL; > ShellStatus = SHELL_SUCCESS; > ParamCount = 0; > FileList = NULL; > + FileHandle = NULL; > > // > // initialize the shell lib (we must be in non-auto-init...) @@ -226,9 +228,17 @@ ShellCommandRunTouch ( > ){ > Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, &FileList); > if (EFI_ERROR(Status)) { > - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"touch", (CHAR16*)Param); > - ShellStatus = SHELL_NOT_FOUND; > - break; > + // > + // try to create the file in case it doesn't exist > + // > + gEfiShellProtocol->CreateFile(Param, 0, &FileHandle); > + gEfiShellProtocol->CloseFile(FileHandle); > + Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, &FileList); > + if (EFI_ERROR(Status)) { > + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"touch", (CHAR16*)Param); > + ShellStatus = SHELL_NOT_FOUND; > + break; > + } > } > // > // make sure we completed the param parsing sucessfully... > -- > 2.7.4 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >