Files

對身份感到困惑

  • September 28, 2012

我繼承了一堆文件,頂部以以下語句開頭

Ident:/some/path/to/a/file

Ident 似乎與 C 編碼和製作文件有關,但我不太確定。我擁有的所有文件都不是原始碼或類似的東西。只是文本文件。

標識的用途是什麼?

C 中的 ident 提供有關已編譯程序或函式的資訊,例如其版本、創建或編輯日期等。一個實用程序,什麼,可以像這樣使用:例如,什麼 func.o,來顯示該資訊。資訊由SCCS、RCS或CVS等原始碼管理系統填寫。

所以假設當你在程式時,你會啟動一個這樣的程序:

標識" $ Id $ "

   /*
    *      Copyright (C) 2000-2012 Your Name
    *
    *      This program is free software; you can redistribute it and/or
    *      modify it under the terms of version 2 of the GNU General
    *      Public License as published by the Free Software Foundation.
    *
    *      This program is distributed in the hope that it will be useful,
    *      but WITHOUT ANY WARRANTY; without even the implied warranty of
    *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    *      General Public License for more details.
    *
    *      You should have received a copy of the GNU General Public
    *      License along with this program; if not, write to the Free
    *      Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
    *      MA 02111-1307, USA.
    */
    /*
    *      Name:           $Source$
    *      Purpose:
    *      Version:        $Revision$
    *      Modified:       $Date$
    *      Author:         Your Name
    *      Date:
    *      $Log$
    */

所以這裡發生的是所有與文件相關的資訊,例如它的版本號,作者姓名等都被記錄下來以備將來參考。

當一個文件包含這些 $ token $ 字元串被放入,比如說,CVS,這些標記將被翻譯成這樣:

   #ident  "$Id: histfile.c,v 1.1.1.1 2011/10/07 18:06:40 trona Exp $"

   /*
    *      Copyright (C) 2000-2012 Your Name
    *
    *      This program is free software; you can redistribute it and/or
    *      modify it under the terms of version 2 of the GNU General
    *      Public License as published by the Free Software Foundation.
    *
    *      This program is distributed in the hope that it will be useful,
    *      but WITHOUT ANY WARRANTY; without even the implied warranty of
    *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    *      General Public License for more details.
    *
    *      You should have received a copy of the GNU General Public
    *      License along with this program; if not, write to the Free
    *      Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
    *      MA 02111-1307, USA.
    *
    *      Name:           $Source: /usr/local/cvsroot/utils/histfile.c,v $
    *      Purpose:        display content of a user's .sh_history file
    *      Version:        $Revision: 1.1.1.0 $
    *      Modified:       $Date: 2012/10/07 18:06:40 $
    *      Author:         Your Name
    *      Date:           24 Jun 2012
    *      $Log: histfile.c,v $
    *      Revision 1.1.1.1  2012/10/07 18:06:40  trona
    *      initial installation Slackware 13.0
    *
    */

這 $ Log $ 令牌很重要;在一個由很多人編輯程式碼的項目中,每次編輯都記錄有註釋,說明做了什麼、為什麼做以及何時完成。

不幸的是,what 實用程序沒有移植到 Linux,但如果您有興趣,可以從 Sourceforge 託管的 The Heirloom Project 獲得。

它有點大,但我希望你能得到你正在尋找的資訊。

你也可以參考這個連結:http ://www.unix.com/programming/26107-what-ident.html

引用自:https://unix.stackexchange.com/questions/49298